I've got a macro defined and I'm trying to test one of the values passed as a parameter to determine how to emit code. However, I keep getting errors thrown when I try to use the value. Here is a simple test that illustrates the problem:
let Test = macro {
case {
_ ($arg1,$arg2,$arg3)
} => {
if ($arg1 ==1) {
return #{
f($arg1,$arg2,$arg3)
}
} else {
return #{
g($arg1,$arg2,$arg3)
}
}
}
}
Test(1,2,3)
The error I get is:
ReferenceError: $arg1 is not defined
I've taken various stabs by calling makeIdent, syntaxUnwrap, etc. without any luck. How can I test the value passed?
Update: After playing around with some things I discovered that I can use this construct to get the value:
#{$arg1}[0].token.value
But then I found this page which suggested that at one point token.value.raw
was used instead of token.value
, which further suggests that since I'm not going through the official documented API I may be accessing undocumented internals which are subject to change.