plugin-lua
plugin-lua copied to clipboard
if conditional return "end" bug
There seems to be a bug when a conditional returns "end" it would break the parser.
if condition then
return "end"
end
See https://github.com/danielpza/plugin-lua/commit/8a4c013f72c6692166070acb3d9982eb4c729175
Could you post the error stack? This is likely a bug in luaparse, though it might just be that we're using an old version.
Sure:
$ prettier --write main.lua
main.lua
[error] main.lua: SyntaxError: [20:0] unexpected keyword 'end' near '<eof>'
[error] at raise (/home/daniel/var/npm/lib/node_modules/@prettier/plugin-lua/node_modules/luaparse/luaparse.js:492:15)
[error] at unexpected (/home/daniel/var/npm/lib/node_modules/@prettier/plugin-lua/node_modules/luaparse/luaparse.js:556:14)
[error] at parseChunk (/home/daniel/var/npm/lib/node_modules/@prettier/plugin-lua/node_modules/luaparse/luaparse.js:1367:29)
[error] at end (/home/daniel/var/npm/lib/node_modules/@prettier/plugin-lua/node_modules/luaparse/luaparse.js:2266:17)
[error] at Object.parse (/home/daniel/var/npm/lib/node_modules/@prettier/plugin-lua/node_modules/luaparse/luaparse.js:2236:31)
[error] at Object.parse (/home/daniel/var/npm/lib/node_modules/@prettier/plugin-lua/src/parser.js:5:19)
[error] at Object.parse (/home/daniel/var/npm/lib/node_modules/prettier/bin-prettier.js:9743:19)
[error] at coreFormat (/home/daniel/var/npm/lib/node_modules/prettier/bin-prettier.js:13258:23)
[error] at format (/home/daniel/var/npm/lib/node_modules/prettier/bin-prettier.js:13516:73)
[error] at formatWithCursor (/home/daniel/var/npm/lib/node_modules/prettier/bin-prettier.js:13532:12)