-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
The following SIGSEGVs:
macro f(x: static[int]): untyped = discard
proc g[X: static[int]](v: f(X)) = discard
This is valid with the type system, though, right? Since X
is known at compile-time it can be used to generate a type for v
? I want to do something like this:
type MyFancyConcreteType = ...
type MyFancyGenericType[N: static[int]] = ...
macro Choose(N: static[int]): untyped =
if N == 2:
return ident("MyFancyConcreteType")
else:
return nnkBracketExpr.newTree(ident("MyFancyGenericType"), newIntLitNode(N))
var x: Choose(2) # of MyFancyConcreteType
var y: Choose(3) # of MyFancyGenericType[3]
# Generic procs may still be written
proc doSomethingWithEither[N: static[int]](v: Choose(N)) = ...
Is this possible, SIGSEGV or no; should I abandon the idea?