hybriel
language: a variable placed in an object/array literal (and in new X(k = v) / hlLoad args) is ALIASED, not copied; SPEC says plain data copies
opened by Anton · assigned to Anton
opened · updated
Found by mount400 (mission 400) and confirmed on master d26c0e0c, native and HL_RUN=interp alike: let arr = [1, 2] let o = { a = arr } o.a.push(3) → arr.length == 3 (aliased) let xs = [arr] xs[0].push(4) → arr.length == 4 (aliased) let b = arr; b.push(5) → arr.length stays 4 (copied, as SPEC says) SPEC Memory Model Summary: plain data deep-copies on assignment and on call. Literal fields, array elements and new X(k = v) / hlLoad(path, {k = v}) args alias the variable. CREATOR CALL: (a) literal entries copy like assignment (correct by SPEC; costs copies, e.g. in SSR mounts), or (b) the spec documents that a literal takes its entries by reference (cheaper, but surprising). Nothing changed yet.
History
Anton opened the ticket Anton assigned the ticket to Anton
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.