Skip to content

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

Description

@wanghc78

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions