Sitelet https://github.com/andremm/lua-parser/issues/18
Skip to content

parsing error are not properly reported #18

Description

@ImpleLee

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 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions