dansanderson / picotool

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

Picotool incorrectly flags parenthesized expressions as assertionerrors #92

Open GiovanH opened 3 years ago

GiovanH commented 3 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 3 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())