Fix: %mem-set OFFSET has no default, unlike %mem-ref - #1813
Open
dg1sbg wants to merge 1 commit into
Open
Conversation
The methods generated for %mem-set took `&optional offset` with no default, while the matching %mem-ref methods took `&optional (offset 0)`. Calling %mem-set with the documented three arguments therefore passed NIL through to %offset-address-as-integer and failed with NIL is not of type INTEGER. so an offset had to be supplied explicitly, unlike %mem-ref: (clasp-ffi:%mem-ref p :float) ; => 0.0 (clasp-ffi:%mem-set p :float 2.5) ; => error (clasp-ffi:%mem-set p :float 2.5 0) ; => ok Both generic functions declare `&optional offset`, so the two accessors were meant to be symmetric; only the generated methods disagreed. Strictly additive: behaviour changes only for the arity-3 call that previously errored. Callers passing an explicit offset are unaffected -- an explicitly supplied NIL means the default form never runs, so that case still errors exactly as before. Adds a regression test to the FFI suite.
dg1sbg
force-pushed
the
pr/mem-set-offset-default
branch
from
August 13, 2026 16:35
afb1ac3 to
2dc8f19
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is broken
The methods generated for
%mem-setinfli.lisptake&optional offsetwith no default, while the matching%mem-refmethods take&optional (offset 0). Calling%mem-setwith the documented three arguments therefore passesNILthrough to%offset-address-as-integerand fails:So an offset must be supplied explicitly to
%mem-setbut not to%mem-ref. Both generic functions declare&optional offset, so the two accessors were plainly meant to be symmetric — only the generated methods disagree.Fix
One token in the
generate-methodsmacrolet:&optional offsetbecomes&optional (offset 0), matching the%mem-refmethod generated three lines above it.Compatibility
Strictly additive. The only arity whose behaviour changes is the 3-argument call, which previously errored unconditionally:
NIL— unchanged, still errors, because an explicitly supplied argument means the default form never runs.No call that worked before behaves differently.
Tests
Adds
mem-set-default-offsetto the FFI suite indefcallback-native.lisp. The pre-existingcffi-defcallbacktest exercises%mem-setwith explicit offsets, so the 4-argument path is covered by an existing test rather than only by argument.Full regression suite on
boehm: 1975 successes, zero unexpected failures (1974 baseline + the new test).Passed MEM-SET-DEFAULT-OFFSET,Passed CFFI-DEFCALLBACK.Found while investigating #1811, but entirely independent of it — this is a plain lambda-list oversight, not related to dispatch.