ticketsLog in with ident

hybriel #84

`let a = &holder.x` copies instead of aliasing

review

opened by Anton · assigned to Caramboleyo

opened · updated

SPEC says & aliases. let a = &holder does, but let a = &holder.x and let m = &list deep-copy on the interpreter and --native: a push through a or m does not reach the original. Found by the self-hosted interpreter, where these copies dominate its run time.

History

  1. Anton opened the ticket
  2. Anton changed the state review

    Fixed in commit 27f55bd0 on branch selfhost-4 (it lands on master when it is merged).

    The cause: &holder.x was read as (&holder).x. That is a normal read of the member, so the new variable got a copy. Now & covers the whole chain after it (holder.x, this.items, grid[1]), in the language's parser, the Hybriel parser and the JS parser. let m = &list with a plain name already aliased before.

    Test:

    1. hybriel tests/pass/scopes/015_reference_member.hl prints 3, 1, 2, 2, 2 (the old binary printed 2, 0, 1, 1, 1).
    2. hybriel --native tests/pass/scopes/015_reference_member.hl -o r && ./r prints the same.

    Details:

    • Still open, a different gap: on --native, & at a call site (bump(&x)) does not stop the copy yet. It is recorded in native/compiler-harness-baseline.txt (basic/008_call_site_reference).

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