You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another issue related to typed macro arguments (nim-lang/RFCs#44).
Example
import macros
type
A =refobjectofRootObj
B =refobjectof A
procf(T: typedesc[A], x: A) =echo"only accepts A"procf(T: typedesc[B], x: B) =echo"only accepts B"macrogenCallToF(t: typed, x: untyped): untyped=result=newCall(ident"f", [t, newCall(t, x)])
echoresult.repr
let x1 =A()
let x2 =B()
# That's the ASTs produced by the macrof(A, A(x1))
f(B, B(x2))
genCallToF(A, x1)
genCallToF(B, x2)
Current Output
The ASTs produced by the macro have different behavior than the manual ASTs:
only accepts A
only accepts B
only accepts A
only accepts A
Expected Output
The should behave the same:
only accepts A
only accepts B
only accepts A
only accepts B
Workaround
It looks like the problem is also caused by using symbols instead of idents. The problem disappears
when changing the macro arg to t: untyped or
when using the infamous "to untyped" trick. In this case it is needed for the type conversion call: newCall(ident t.strVal, x).
Additional Information
$ nim -v
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-04-13
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: f6ad071a46a2bec57db453343d8d8b75d3d16ac2
active boot switches: -d:release
Another issue related to typed macro arguments (nim-lang/RFCs#44).
Example
Current Output
The ASTs produced by the macro have different behavior than the manual ASTs:
Expected Output
The should behave the same:
Workaround
It looks like the problem is also caused by using symbols instead of idents. The problem disappears
t: untyped
ornewCall(ident t.strVal, x)
.Additional Information
Relevant project: https://github.com/bluenote10/oop_utils
The text was updated successfully, but these errors were encountered: