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

parsing error are not properly reported #18

Closed
ImpleLee opened this issue May 5, 2022 · 5 comments
Closed

parsing error are not properly reported #18

ImpleLee opened this issue May 5, 2022 · 5 comments

Comments

@ImpleLee
Copy link

ImpleLee commented May 5, 2022

Steps to reproduce

  1. create an empty directory in /tmp and cd into it.
  2. pip install hererocks
  3. hererocks . -r^ --lua=5.3
  4. ./bin/luarocks install lua-parser
  5. copy the code example in README as parse.lua:
local parser = require "lua-parser.parser"
local pp = require "lua-parser.pp"

if #arg ~= 1 then
    print("Usage: parse.lua <string>")
    os.exit(1)
end

local ast, error_msg = parser.parse(arg[1], "example.lua")
if not ast then
    print(error_msg)
    os.exit(1)
end

pp.print(ast)
os.exit(0)
  1. ./bin/lua parse.lua "for i=1, 10 do print(i)"

Expected behavior

example.lua:1:24: syntax error, expected 'end' to close the for loop

Actual behavior

./bin/lua: ./share/lua/5.3/lua-parser/parser.lua:478: attempt to get length of a number value (local 'sfail')
stack traceback:
	./share/lua/5.3/lua-parser/parser.lua:478: in function 'lua-parser.parser.parse'
	parse.lua:9: in main chunk
	[C]: in ?
@ImpleLee
Copy link
Author

ImpleLee commented May 5, 2022

System Information

$ uname -srvmo
Linux 5.4.0-109-generic #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022 x86_64 GNU/Linux

@ImpleLee
Copy link
Author

ImpleLee commented May 5, 2022

Package Information

$ ./bin/luarocks list

Rocks installed for Lua 5.3
---------------------------

lpeglabel
   1.6.0-1 (installed) - ./lib/luarocks/rocks-5.3

lua-parser
   1.0.1-1 (installed) - ./lib/luarocks/rocks-5.3

@ImpleLee
Copy link
Author

ImpleLee commented May 5, 2022

I think this is maybe just #15 again...

@ImpleLee
Copy link
Author

ImpleLee commented May 5, 2022

In rockspec of 1.0.1, the tag is specified as v1.0.0, so users from luarocks will just use the wrong code...

@ImpleLee ImpleLee changed the title parsing error cannot be properly reported parsing error are properly reported May 5, 2022
@ImpleLee ImpleLee changed the title parsing error are properly reported parsing error are not properly reported May 5, 2022
@andremm
Copy link
Owner

andremm commented May 15, 2022

5. ./bin/lua parse.lua "for i=1, 10 do print(i)"

Thanks for spotting this issue and sorry for the inconvenience. I just pushed a new release that should solved this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants