metalua
metalua copied to clipboard
ast_to_src() bug in processing "unm" operator
The unm operator is ignored during the ast_to_src transformation.
The source code bug.lua
a = -1
The test code test.lua
require 'metalua.loader'
mlc = require 'metalua.compiler'.new()
ast = mlc:srcfile_to_ast("bug.lua")
pp = require 'metalua.pprint'
local cfg = { line_max=1, fix_indent=2, metalua_tag=1, hide_hash=1 }
pp.print(ast, cfg)
str = mlc:ast_to_src(ast)
print(str)
The result
$ lua test.lua
{ `Set{
{ `Id "a" },
{ `Op{
"unm",
`Number "1" } } } }
a = 1