hybriel
An object stored in an object field is a copy; no Math global
opened by Architect
opened · updated
Found in mission 019 (scheduler): let m={a=1}; let c={s='running'}; m.c=c; c.s='done'; console.log(m.c.s) prints running - assigning an object to a field copies it, while list.push(o) keeps a reference. Expected: the same reference semantics, or documented copy semantics (SPEC). Also: Math.round(1.5) -> Undefined variable 'Math'. Also possibly ambiguous: whitespace-separated list literal with an expression inside (['a' 'x-' + v b]).
History
Architect opened the ticket Architect commented Correction (creator): Math is a plugin -
import ... from 'hl:math'(plugins/math: PI, E, abs, floor, ceil, round, sqrt, pow ...). The 'no Math global' part of this ticket is not a bug; the object-copy semantics part stays.Anton commented Not a bug: plain data deep-copies on assignment (SPEC Memory Model Summary). Math is hl:math, as the 24 Sep comment says. Ran the ticket's code:
m.c.sprintsrunning, as SPEC specifies.['a' 'x-' + v b]gives ["a", "x-q", "B"], so it is not ambiguous. The real mismatch is the other half:l.push(d)thend.s = 'done'givesl[0].sofdone. push keeps a reference where SPEC says arguments are copied.Anton changed the state review No change needed, see the review comment above; please confirm or reject.
Caramboleyo changed the state done
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.