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

ast_to_src() bug in processing "unm" operator #25

Open
wanghc78 opened this issue Jul 15, 2014 · 0 comments
Open

ast_to_src() bug in processing "unm" operator #25

wanghc78 opened this issue Jul 15, 2014 · 0 comments

Comments

@wanghc78
Copy link

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
astadmistry added a commit to astadmistry/metalua that referenced this issue Nov 21, 2019
ast2src cannot handle minus (fab13n#25)

Credits: wanghc78 (fab13n#26)
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

1 participant