edubart / nelua-lang

Minimal, efficient, statically-typed and meta-programmable systems programming language heavily inspired by Lua, which compiles to C and native code.
https://nelua.io
MIT License
2.05k stars 66 forks source link

Typo: macro example code doesn't use its parameter #214

Closed RaycatWhoDat closed 1 year ago

RaycatWhoDat commented 1 year ago

Screenshot

Expected behavior

str should be used instead of the string literal 'hello'.

Workaround

This works as intended if you write it with the parameter. This is just a typo.

##[[
-- create a macro that injects a custom node when called
local function print_macro(str)
  local node = aster.Call{{aster.String{str}}, aster.Id{"print"}}
  -- inject the node where this macro is being called from
  inject_astnode(node)
end
]]

## print_macro('hello (again)')

Output:

print('hello (again)')
edubart commented 1 year ago

Fixed.