Repository navigation
Bitwise results are s32; an empty [] in a conditional; references laid out alike (TSLANG 24-26) - #775
Merged
Merged
Conversation
…d out alike (TSLANG 24-26) - 24: `[1 << 18, w]` with `w: int` was an s64 array. Shifts, `&`, `|` and `^` cast their operands to a signless i32, and a signless integer merged with a signed one widens to s64 (the rule meant for lengths). They are ToInt32's signed 32-bit integer now, as `int` is; `>>>` keeps its unsigned result. `typeof (a & 1)` is "s32". - 25: `cond ? [1] : []` crashed when iterated: `[]` is an empty `any` array, and the merge was a union `s32[] | any[]` that `for...of` read through its tag. An empty array literal takes the other branch's array type, as TypeScript gives it. - 26: `Ref(numbers[0])` passed to a `Ref<f32>` handed a `double*` on as a `float*`. A reference to a scalar number cast to one to a number laid out otherwise is an error now. Tests 00tslang_issues_24_26 (gc, rc, none, own) and ref_element_layout_error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Nov 6, 2026
…interprets again #775 made a reference to a number cast to one laid out otherwise an error, in cast(), which explicit assertions reach too. The default library's HashHelpers.hashCodeGeneral reads a number key's bits through `<Reference<i32>>Ref(key)`, so every Map/Set with number keys failed to compile (map_get_number, map_negative_keys, map_size_delete under every model). Found by the pre-release default-library check before tagging. An assertion between two reference types is a plain reinterpreting cast again, as before #775; the layout check stays for implicit conversions (a call's argument, an assignment). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Nov 6, 2026
…interprets again (#776) #775 made a reference to a number cast to one laid out otherwise an error, in cast(), which explicit assertions reach too. The default library's HashHelpers.hashCodeGeneral reads a number key's bits through `<Reference<i32>>Ref(key)`, so every Map/Set with number keys failed to compile (map_get_number, map_negative_keys, map_size_delete under every model). Found by the pre-release default-library check before tagging. An assertion between two reference types is a plain reinterpreting cast again, as before #775; the layout check stays for implicit conversions (a call's argument, an assignment). Co-authored-by: Claude Opus 5.5 <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.
Fixes TSLANG_ISSUES 24, 25 and 26, found in native_ts_graphics' powder_sandbox_nri.
[1 << 18, w]withw: intwas an s64 array. Shifts,&,|and^cast their operands to a signlessi32. A signless integer merged with a signed one widens tos64, a rule meant for lengths, soRef(header[0])handed a Cint*8-byte elements. These operators now give ToInt32's signed 32-bit integer, asintis;>>>keeps its unsigned result. Visible change:typeof (a & 1)iss32, wasi32. The values printed are unchanged.cond ? [1] : []crashed infor...of.[]is an emptyanyarray (const_array<any, 0>), so the conditional became a unions32[] | any[]. An empty array literal now takes the other branch's array type, as TypeScript gives it (number[]).Ref(numbers[0])passed to aRef<f32>handed adouble*on as afloat*, with no diagnostic. A reference to a scalar number cast to a reference to a number laid out otherwise (another width, or float against integer) is now an error: "a reference to number can't be used as a reference to f32: what it refers to is laid out otherwise".The issue write-ups are committed as they were reported. A follow-up commit marks them fixed.
Tests
00tslang_issues_24_26: the three repros, nested and empty-first conditionals, and references laid out alike. Runs compiled and under JIT with gc, rc, none and own.ref_element_layout_error: the error, added to the ownership verifier's skip list.ctest -C Release: 6670 tests, all passing.🤖 Generated with Claude Code