moonscript icon indicating copy to clipboard operation
moonscript copied to clipboard

Table Comprehension Leads to Silent Error in Destructuring Assignment

Open turbo opened this issue 4 years ago • 1 comments

Receivers in LHS will be nil when destructuring is used on table comprehensions. No error emitted by the compiler:

foo = "1 2 foobar"

-- works as expected:
items = [ w for w in foo\gmatch("%S+") ]
{one, two, three} = items

-- all receivers nil:
{one, two, three} = [ w for w in foo\gmatch("%S+") ]

This contradicts other behavior where table comprehension expressions can be used instead of variable identifiers which contain tables.

turbo avatar Jul 24 '19 13:07 turbo

Possibly a dupe: #449

fwcd avatar Dec 12 '23 12:12 fwcd