Skip to content

Bitwise results are s32; an empty [] in a conditional; references laid out alike (TSLANG 24-26) - #775

Merged
ASDAlexander77 merged 3 commits into
mainfrom
tslang-issues-24-26
Nov 6, 2026
Merged

ASDAlexander77 merged 3 commits into
mainfrom
tslang-issues-24-26

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Fixes TSLANG_ISSUES 24, 25 and 26, found in native_ts_graphics' powder_sandbox_nri.

  • 24: [1 << 18, w] with w: int was an s64 array. Shifts, &, | and ^ cast their operands to a signless i32. A signless integer merged with a signed one widens to s64, a rule meant for lengths, so Ref(header[0]) handed a C int* 8-byte elements. These operators now give ToInt32's signed 32-bit integer, as int is; >>> keeps its unsigned result. Visible change: typeof (a & 1) is s32, was i32. The values printed are unchanged.
  • 25: cond ? [1] : [] crashed in for...of. [] is an empty any array (const_array<any, 0>), so the conditional became a union s32[] | any[]. An empty array literal now takes the other branch's array type, as TypeScript gives it (number[]).
  • 26: Ref(numbers[0]) passed to a Ref<f32> handed a double* on as a float*, 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.
  • Full ctest -C Release: 6670 tests, all passing.

🤖 Generated with Claude Code

ASDAlexander77 and others added 3 commits November 6, 2026 18:40
…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
ASDAlexander77 merged commit 5d22776 into main Nov 6, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the tslang-issues-24-26 branch November 6, 2026 19:11
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant