Skip to content

Temporary assignments to map or array members leave them always set to $nil #1515

@hanche

Description

@hanche

I honestly don't know what should happen when you temporarily assign to a map or array member, but all these results seem wrong, or at least surprising:

Exhibit 1:

⬥ var x = [&y=1]
⬥ { tmp x[y] = 2; put $x }
⮕ [&y=2]
⬥ put $x
⮕ [&y=$nil]

Exhibit 2:

⬥ var x = [&y=1]
⬥ { tmp x[z] = 2; put $x }
⮕ [&y=1 &z=2]
⬥ put $x
⮕ [&y=1 &z=$nil]

Exhibit 3:

⬥ var x = [1 2 3]
⬥ { tmp x[1] = 9; put $x }
⮕ [1 9 3]
⬥ put $x
⮕ [1 $nil 3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    ✅Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions