Crash when shebang is not on first line
Hi,
With the following source:
(This is blank line )
#!/usr/bin/lua
return
Running lua I get:
$ lua /tmp/main.lua
lua: /tmp/main.lua:2: unexpected symbol near '#'
I know provided code is not valid, but it would be nice to terminate more nicely.
But running Metalua, I get:
$ metalua /tmp/main.lua
Cannot compile `File "/tmp/main.lua":
mlp_misc.lua:172: attempt to perform arithmetic on field 'line' (a nil value)
I fixed the bug in AST building, but there is still a bug in interacting console. It looks like it related to byte code dumping. Am I doing it wrong? Here is the trace:
$metalua /tmp/main.lua
/usr/bin/lua: lopcodes.lua:186: attempt to perform arithmetic on local 'x' (a nil value)
stack traceback:
lopcodes.lua:186: in function 'keep'
lopcodes.lua:201: in function 'Instruction'
ldump.lua:277: in function 'DumpCode'
ldump.lua:387: in function 'DumpFunction'
ldump.lua:359: in function 'DumpProtos'
ldump.lua:389: in function 'DumpFunction'
ldump.lua:411: in function 'dump'
ldump.lua:428: in function 'dump_string'
compiler/mlc.mlua:144: in function 'f'
compiler/mlc.mlua:165: in function 'ast_to_luacstring'
compiler/metalua.mlua:199: in function 'main'
compiler/metalua.mlua:258: in main chunk
(tail call): ?
[C]: ?
tu peux essayer avec ca dans lexer.ml?
function M.skip_initial_sharp_comment (lx) -- Dirty hack: I'm happily fondling lexer's private parts -- FIXME: redundant with lexer:newstream() lx :sync() local i = lx.src:match ("^#.-\n()", lx.i) if i then lx:sync(); self.i=i end end
On Thu, Jan 31, 2013 at 3:56 PM, Kevin KIN-FOO [email protected]:
I fixed the bug in AST building, but there is still a bug in interacting console. It looks like it related to byte code dumping. Am I doing it wrong? Here is the trace:
$metalua /tmp/main.lua /usr/bin/lua: lopcodes.lua:186: attempt to perform arithmetic on local 'x' (a nil value) stack traceback: lopcodes.lua:186: in function 'keep' lopcodes.lua:201: in function 'Instruction' ldump.lua:277: in function 'DumpCode' ldump.lua:387: in function 'DumpFunction' ldump.lua:359: in function 'DumpProtos' ldump.lua:389: in function 'DumpFunction' ldump.lua:411: in function 'dump' ldump.lua:428: in function 'dump_string' compiler/mlc.mlua:144: in function 'f' compiler/mlc.mlua:165: in function 'ast_to_luacstring' compiler/metalua.mlua:199: in function 'main' compiler/metalua.mlua:258: in main chunk (tail call): ? [C]: ?
— Reply to this email directly or view it on GitHubhttps://github.com/fab13n/metalua/issues/19#issuecomment-12945934.
Fabien Fleutot +--- | 33 chemin de Mange-Pommes | 31520 Ramonville Saint-Agne -- France | mobile: +33 6 28 06 09 97 | office: +33 5 61 00 06 49 | home: +33 5 61 75 05 67