Macros are broken (outside of the online REPL)
SkyyySi opened this issue · 3 comments
The code
macro INVERT = (var) ->
"#{var} = not #{var}"
$INVERT(x)
used to be valid and produce the following Lua code:
local x = 5;
x = not x
However, after having installed Yuescript 0.16.5, this behavior seems to be broken, with it now resulting in the following compilation error:
Failed to compile: test2.yue
5: left hand expression is not assignable
$INVERT(x)
^
However, weirdly, the online REPL seems to be unaffected by this.
Can you show me the full codes in your "test2.yue" ?
Can you show me the full codes in your "test2.yue" ?
Sure:
macro INVERT = (var) ->
print(var)
"#{var} = not #{var}"
$INVERT(x)
The print statement prints that var
is a nil
value (note to self: why did strip that line out? That sounds like it's quite important here).
For good measure, I also tested this in the interactive (offline) REPL:
macro test = (x, y, z) -> "'#{x}, #{y}, #{z}'"
When running that code as $test("foo", "bar", "biz")
, I get back the string nil, nil, nil
.
In case that helps, here's some info on my specific setup (since this issue doesn't occur in the online REPL, this issue may be related to that):
- OS: Arch Linux
- Lua version: 5.1
- Install method:
sudo luarocks install --lua-version=5.1 yuescript
I think the previous version of Yuescript I used was 0.16.1, but I also recently compiled just fine on a different, more recent setup on my laptop, so I'm guessing that this issue was only introduced in 0.16.5 or maybe 0.16.4.