An explicitly-undef optional argument means absent, not bad - #125
Merged
Conversation
BOSL2 reaches a builtin whose name it also defines by wrapping it in
builtins.scad, which use<>s nothing -- so the names in that file bind
to the builtins rather than to BOSL2's own:
function _linear_solve(A, b) = linear_solve(A, b);
That wrapper has a fixed signature, so a determinant()-style caller
passing no right-hand side still forwards b as undef. We treated that
as a bad argument: warning on every call and returning undef, which
made determinant() unusable through the wrapper.
Passing undef is idiomatically the same as not passing in OpenSCAD --
it is how BOSL2 threads optional arguments through wrappers
everywhere -- so undef now counts as absent. Same fix for levelset's
isovalue, which had the identical problem waiting.
Found by testing BOSL2's actual delegation plan rather than assuming
it would work. The whole pattern now runs clean on both engines:
square [1,3], det 5, least-squares [-1.4,3.1], minimum-norm
[0.333,2.333,2.667], singular [], no warnings.
The wrapper mechanism itself was verified against OpenSCAD 2026.02.01
first: a function defined in a use<>d file that includes nothing sees
the builtin, while the caller's own definition still shadows it at the
call site. We match exactly.
1064 tests pass under both engines.
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.
BOSL2 reaches a builtin whose name it also defines by wrapping it in
builtins.scad— a file thatuse <>s nothing, so the names inside it bind to the builtins rather than to BOSL2's own definitions:That wrapper has a fixed signature, so a
determinant()-style caller that passes no right-hand side still forwardsbasundef. We treated that as a bad argument — warning on every call and returningundef, which madedeterminant()unusable through the wrapper.Passing
undefis idiomatically the same as not passing in OpenSCAD — it's how BOSL2 threads optional arguments through wrappers everywhere (_cylinder(h,r1,r2,center,r,d,d1,d2)forwards all eight, most of them undef). So undef now counts as absent.Same fix applied to
levelset'sisovalue, which had the identical problem waiting.How it was found
By testing BOSL2's actual delegation plan rather than assuming it would work. First the mechanism, against OpenSCAD 2026.02.01:
Identical on both our engines. Then the full
linear_solvepattern end to end, which is where the undef problem surfaced. It now runs clean:No warnings, both engines.
Two regression tests added, one per builtin. 1064 tests pass under both engines.
Version 0.50.0 → 0.50.1.
🤖 Generated with Claude Code