metalua icon indicating copy to clipboard operation
metalua copied to clipboard

ast_to_src() bug in processing "unm" operator

Open wanghc78 opened this issue 11 years ago • 0 comments

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

wanghc78 avatar Jul 15 '14 20:07 wanghc78