You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NL2290 does not follow a const alias of an element reference: a stale record is read after a push (native 1, Node 42) #646
NL2290 refuses a read through a reference to an array element after a push may have moved the array's storage. It does not follow a second const that aliases that reference. The program below compiles. Natively it reads the record from the old storage; under Node it reads the live one.
interfaceP{x: i32;}constreadX=(p: P): i32=>p.x;exportconstmain=(): i32=>{constps: P[]=[];for(leti: i32=0;i<4;i++){ps.push({x: 1});}constp=ps[0];constq=p;// alias of the element referencefor(leti: i32=0;i<1000;i++){ps.push({x: 5});}ps[0].x=42;console.log(`${readX(q)}`);// NL2290 fires for `p` here, not for `q`return0;};
Native, at 1, 2 and 8 threads: prints 1.
Node: prints 42.
The program is single-threaded. It reproduces on main at 6729c7c and on #644's head.
Through a task capture, the same alias (s.spawn(() => readX(q)) after a push) is harmless today. The parent cannot write before the join, and grown storage is not freed. That holds only because of those two facts.
Activity