An array inside a tuple literal built at run time cannot be changed through the tuple. There are two shapes.
1. A constant array inside a tuple that has a run-time value: push does not resolve, with let or const.
function main() {
let x = 3;
let t = [x, [1]];
t[1].push(2);
print(t[1].length);
}
error: Can't resolve property 'push' of type s32[]
The tuple's type is tuple<number, const_array<si32, 1>>: the inner literal keeps its constant-array type instead of being widened to s32[] (createTupleFromArrayLiteral takes each value's type as is).
Expected: 2.
2. A const of a run-time tuple has no storage: an array in it cannot be changed.
function main() {
let x = 3;
const nt = [x, [2, [3, 4]]];
nt[1][1].push(5);
print(nt[1][1].length);
}
error: Can't get reference of the array, ensure const array is not used
Expected: 3. With let nt it prints 3 (since #484; on main the let form crashes, which was #479).
processConstRef gives a const storage for a constant array, an array, a constant tuple holding an array (#484), a record read from a literal slot that owns memory, and a few other cases. A tuple built by ts.CreateTuple with an array inside is not among them, so nt is folded to the SSA value, and push has no reference to work through.
Both shapes give the same errors on main (77d9a6a) and with #484.
Found while testing #484 (#479).
🤖 Generated with Claude Code
An array inside a tuple literal built at run time cannot be changed through the tuple. There are two shapes.
1. A constant array inside a tuple that has a run-time value:
pushdoes not resolve, withletorconst.The tuple's type is
tuple<number, const_array<si32, 1>>: the inner literal keeps its constant-array type instead of being widened tos32[](createTupleFromArrayLiteraltakes each value's type as is).Expected:
2.2. A
constof a run-time tuple has no storage: an array in it cannot be changed.Expected:
3. Withlet ntit prints3(since #484; on main theletform crashes, which was #479).processConstRefgives aconststorage for a constant array, an array, a constant tuple holding an array (#484), a record read from a literal slot that owns memory, and a few other cases. A tuple built byts.CreateTuplewith an array inside is not among them, sontis folded to the SSA value, andpushhas no reference to work through.Both shapes give the same errors on main (77d9a6a) and with #484.
Found while testing #484 (#479).
🤖 Generated with Claude Code