dansanderson / picotool

Tools and Python libraries for manipulating Pico-8 game files. http://www.lexaloffle.com/pico-8.php
MIT License
367 stars 46 forks source link

Picotool incorrectly flags parenthesized expressions as assertionerrors #92

Open GiovanH opened 2 years ago

GiovanH commented 2 years ago

The error message for all of these cases is always AssertionError, thrown at self._tokens[self._pos].matches(lexer.TokSymbol(keyword)) in lua.py.

Parenthesized functions AssertionError (expected ) got ():

dbg=(function()
end)()

Correctly parsed:

dbg=function()
end
dbg = dbg()

Parenthesized tables AssertionError (expected ) got :): (note: tables have __sub methods defined in metatables)

somefunction({(table1 - table2):unpack()}))

Correctly parsed:

local temp = (self.pos - self.anchor)
somefunction({temp:unpack()}))
GiovanH commented 2 years ago

This can temporarily be worked around by replacing operators that require parentheticalization with their dunder builtin function equivalents:

This code (which is correct, but p8tool cannot parse)

somefunction((table1 - table2):unpack())

becomes

somefunction(table1:__sub(table2):unpack())