Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destructuring a list comprehension produces invalid code #411

Open
s-ol opened this issue Feb 19, 2020 · 0 comments
Open

destructuring a list comprehension produces invalid code #411

s-ol opened this issue Feb 19, 2020 · 0 comments

Comments

@s-ol
Copy link

@s-ol s-ol commented Feb 19, 2020

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

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

do
  local _accum_0 = { }
  local _len_0 = 1
  local _list_0 = {
    1,
    2,
    3
  }
  for _index_0 = 1, #_list_0 do
    local a = _list_0[_index_0]
    _accum_0[_len_0] = a * 2
    _len_0 = _len_0 + 1
  end
  local a, b, c
  a, 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}]
@s-ol s-ol changed the title Table destructuring and List Comprehension produce invalid code destructuring a list comprehension produces invalid code Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.