Report 2026.01.01, and take version_num()'s optional vector - #98
Merged
Conversation
Two fixes to the version builtins: version()/version_num() reported 2025.01.01, a release that never existed. The OpenSCAD release to track is 2026.01.01 (tag openscad-2026.01.01-TEST2, the first tagged build carrying hex literals and the object() function), so version() is [2026, 1, 1] and version_num() is 20260101. version_num() also ignored the optional vector argument the reference accepts, always answering with our own release: version_num([2019, 5, 0]) returned 20250101 instead of 20190500. It now folds whatever it is handed, via the reference's own y * 10000 + m * 100 + d, with getVec3's 2-element form defaulting the day to 0. A non-list, a wrong length, or a non-numeric element is undef. One deliberate divergence, commented at the call site: the reference's size-2 path ignores getVec2's own failure and folds uninitialized doubles, so real OpenSCAD answers version_num(["a", "b"]) with garbage (measured: 3.81052e+286). We return undef there instead. Every other case was checked against real OpenSCAD 2022.08.22 directly -- [2019,5,0], [2019,5], 5, undef, [2019], [2019,5,0,7] and ["a","b","c"] all match exactly. VersionReturnsThreeElementList only asserted the list's length, so it could not have caught a wrong release; it now pins the values alongside version_num()'s, which is the point of the pair. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Two fixes
1. Wrong release reported.
version()/version_num()returned2025.01.01— a release that never existed. The OpenSCAD release we track is 2026.01.01 (tagopenscad-2026.01.01-TEST2, the first tagged build carrying hex literals and theobject()function). Soversion()is now[2026, 1, 1]andversion_num()is20260101.2.
version_num()ignored its optional argument. The reference accepts a version vector and folds that, not the running release. We always answered with our own —version_num([2019, 5, 0])returned20250101instead of20190500. Now folded via the reference's owny * 10000 + m * 100 + d, withgetVec3's 2-element form defaulting the day to 0. A non-list, a wrong length, or a non-numeric element isundef.Verified against real OpenSCAD 2022.08.22
Ran the same script through
/Applications/OpenSCAD.app:version_num([2019,5,0])20190500version_num([2019,5])20190500version_num(5)undefversion_num(undef)undefversion_num([2019])undefversion_num([2019,5,0,7])undefversion_num(["a","b","c"])undefversion_num(["a","b"])3.81052e+286undef— deliberateThat last row is a real bug in the reference: its size-2 path ignores
getVec2's own failure and folds uninitialized doubles. We returnundefrather than copy the undefined behavior. Commented at the call site.Tests
VersionNumFoldsAGivenVersionVector— the 3- and 2-element formsVersionNumRejectsAnythingButA2Or3NumberVector— all sixundefcasesVersionReturnsThreeElementListonly checked the list's length, so it could never have caught a wrong release; it now pins the values alongsideversion_num()'s867 tests pass, under both
OSCAD_BYTECODE_VM=0and=1.Version bumped 0.32.1 → 0.32.2.
🤖 Generated with Claude Code