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
I try to generate the entire tree of nnkObjectTy for a generic type entirely in a macro. In some very very limited contexts this is already possible, but as soon as I generate an actiual node of nnkObjectTy or nnkTupleTy, the compiler complains and says that it is either illegal or it can't generate VM code. Here is the example to reproduce the problem:
import macros
macrogenTypeA(arg: typed): untyped=if arg.typeKind != ntyTypeDesc:
error("expected typedesc", arg)
result= arg.getTypeInst[1]
macrogenTypeB(arg: typed): untyped=if arg.typeKind != ntyTypeDesc:
error("expected typedesc", arg)
let typeSym = arg.getTypeInst[1]
result=
nnkTupleTy.newTree(
nnkIdentDefs.newTree(
ident"a", typeSym, newEmptyNode()
)
)
type# this is the trivial case, MyTypeA[T] is basically just T, nothing else. But it works.MyTypeA[T] =genTypeA(T)
# in this case I generate `tuple[a: T]`. This this is something the compiler does not wantMyTypeB[T] =genTypeB(T)
# these are just alias types for int32 and float32, nothing really happens, but it worksvar a1: MyTypeA[int32]
var a2: MyTypeA[float32]
var a3: MyTypeA[float32]
var b1: MyTypeB[int32] # cannot generate VM code fur tuple[a: int32]var b2: MyTypeB[float32]
var b3: MyTypeB[float32]
The text was updated successfully, but these errors were encountered:
I try to generate the entire tree of nnkObjectTy for a generic type entirely in a macro. In some very very limited contexts this is already possible, but as soon as I generate an actiual node of nnkObjectTy or nnkTupleTy, the compiler complains and says that it is either illegal or it can't generate VM code. Here is the example to reproduce the problem:
The text was updated successfully, but these errors were encountered: