-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
whitelist generic params matching
typedesc
for templates/macros
fixes #23432
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import std/[sequtils, macros] | ||
|
||
block: # issue #23432 | ||
type | ||
Future[T] = object | ||
InternalRaisesFuture[T, E] = object | ||
|
||
macro Raising[T](F: typedesc[Future[T]], E: varargs[typedesc]): untyped = | ||
## Given a Future type instance, return a type storing `{.raises.}` | ||
## information | ||
## | ||
## Note; this type may change in the future | ||
E.expectKind(nnkBracket) | ||
|
||
let raises = nnkTupleConstr.newTree(E.mapIt(it)) | ||
nnkBracketExpr.newTree( | ||
ident "InternalRaisesFuture", | ||
nnkDotExpr.newTree(F, ident"T"), | ||
raises | ||
) | ||
|
||
type X[E] = Future[void].Raising(E) | ||
|
||
proc f(x: X) = discard | ||
|
||
|
||
var v: Future[void].Raising([ValueError]) | ||
f(v) |