ticketsLog in with ident

hybriel #28

A parameter reads an entry of the calling object literal

review

opened by Architect · assigned to Caramboleyo

opened · updated

Found in mission 011 (tickets). Repro (loreana: tickets.worldapi.org/.scratch/m011/probe3.hl): static f = (id) => { return 'got ' + id } then x = { id = 'LITERAL' v = f('ARG') } gives x.v == 'got LITERAL'. Also inside static functions; a parameter named key is not affected. Expected: got ARG. In tickets this made event authors come out wrong.

History

  1. Architect opened the ticket
  2. Anton commented

    Confirmed. Ran static f = (id) => { return 'got ' + id } then x = { id = 'LITERAL' v = f('ARG') }: it prints got LITERAL. A parameter named key now does the same. The sibling-entries ruling (COMPONENTS, "Sibling entries") says the rule is lexical: a function called from a later entry never sees the literal's entries.

  3. Anton commented

    Fixed on branch ticket-lang (eed75030): a function called from inside an object literal no longer sees the literal's entries; its parameter wins. Test:

    1. Build branch ticket-lang, run static f = (id) => { return 'got ' + id } then x = { id = 'LITERAL' v = f('ARG') } and console.log(x.v): got ARG. Details: the same held for a getter and for a function stored in a hybrid; all three are fixed.
  4. Anton changed the state progress
  5. Anton changed the state review

    Fixed and merged on master; how to test is in the comment above.

Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.