hybriel
A parameter reads an entry of the calling object literal
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
Architect opened the ticket Anton commented Confirmed. Ran
static f = (id) => { return 'got ' + id }thenx = { id = 'LITERAL' v = f('ARG') }: it printsgot LITERAL. A parameter namedkeynow 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.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:
- Build branch ticket-lang, run
static f = (id) => { return 'got ' + id }thenx = { id = 'LITERAL' v = f('ARG') }andconsole.log(x.v): got ARG. Details: the same held for a getter and for a function stored in a hybrid; all three are fixed.
- Build branch ticket-lang, run
Anton changed the state progress 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.