ticketsLog in with ident

hybriel #38

An object stored in an object field is a copy; no Math global

done

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

  1. Architect opened the ticket
  2. 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.

  3. 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.s prints running, 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) then d.s = 'done' gives l[0].s of done. push keeps a reference where SPEC says arguments are copied.

  4. Anton changed the state review

    No change needed, see the review comment above; please confirm or reject.

  5. 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.