Skip to content

destructuring a list comprehensions and loops produces invalid code #411

Description

@s-ol
{ a, b, c }=[a *2for a in*{1,2,3}]

in http://moonscript.org/compiler/:

dolocal_accum_0= { }
local_len_0=1local_list_0= {
1,
2,
3
}
for_index_0=1, #_list_0dolocala=_list_0[_index_0]
_accum_0[_len_0] =a*2_len_0=_len_0+1endlocala, b, ca, b, c=_accum_0[1], _accum_0[2], _accum_0[3]
end

leading to undefined reference to global errors in very unexpected ways.
Temporary workaround is to manually declare a,b,c like so:

local a, b, c
{ a, b, c } = [a * 2 for a in *{ 1, 2, 3}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions