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

build command throws IndexError #62

Open
ditrytus opened this issue Sep 9, 2019 · 2 comments
Open

build command throws IndexError #62

ditrytus opened this issue Sep 9, 2019 · 2 comments

Comments

@ditrytus
Copy link

ditrytus commented Sep 9, 2019

An attempt to run a command

p8tool build --lua ./src/main.lua --gfx ./carts/assets.p8 ./carts/out.p8

throws a following Error

Traceback (most recent call last):
  File "/Users/jakubgruszecki/Documents/picotool/p8tool", line 8, in <module>
    sys.exit(tool.main(sys.argv[1:]))
  File "/Users/jakubgruszecki/Documents/picotool/pico8/tool.py", line 596, in main
    return args.func(args)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/build/build.py", line 258, in do_build
    lua_path=getattr(args, 'lua_path', None))
  File "/Users/jakubgruszecki/Documents/picotool/pico8/build/build.py", line 158, in _evaluate_require
    _evaluate_require(reqd_lua, reqd_filepath, package_lua, lua_path=lua_path)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/build/build.py", line 158, in _evaluate_require
    _evaluate_require(reqd_lua, reqd_filepath, package_lua, lua_path=lua_path)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/build/build.py", line 155, in _evaluate_require
    reqd_lua.reparse(writer_cls=lua.LuaASTEchoWriter)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 178, in reparse
    version=self.version)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 132, in from_lines
    result.update_from_lines(lines)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 141, in update_from_lines
    self._lexer.process_lines(lines)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lexer.py", line 479, in process_lines
    for line in lines:
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 159, in to_lines
    for line in writer.to_lines():
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 943, in to_lines
    for chunk in self.walk():
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 247, in walk
    for t in self._walk(self._root):
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 930, in _walk
    for t in super()._walk(node):
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 228, in _walk
    for t in result:
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 535, in _walk_Chunk
    yield self._get_semis(node)
  File "/Users/jakubgruszecki/Documents/picotool/pico8/lua/lua.py", line 522, in _get_semis
    if self._tokens[self._pos].matches(lexer.TokSymbol(b';')):
IndexError: list index out of range

My project on which picotool crashes is in this repo:
https://github.com/ditrytus/coffee-central

@ditrytus
Copy link
Author

The error was caused by of one of my .lua files missing an empty line at the end.

I don't know why is that required, but if it is, then a more readable error message would help.

@hsandt
Copy link

hsandt commented Dec 30, 2019

No guaranteed fix, but for local work I use my own branch of picotool which adds a bunch of try-except, error messages and empty checks. You may find some ideas here:

hsandt@b7c5dbc#diff-04cb0a489a4e9fbe769aec633ed314ebR546

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