Allow std/macros.params to work with nnkProcTy (#19563)

* Allow std/macros.params to work with nnkProcTy

* Add tests for proc params & pragma
This commit is contained in:
Tanguy 2022-02-25 12:57:58 +01:00 • committed by GitHub
commit ef3f343ec2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 4 deletions

View file

@ -0,0 +1,22 @@
import std/macros
import stdtest/testutils
macro test1(prc: untyped): untyped =
assertAll:
prc.params.len == 2
prc.params[1].len == 4
prc.pragma.len == 2
prc.params = nnkFormalParams.newTree(
ident("int")
)
prc.pragma = newEmptyNode()
assertAll:
prc.params.len == 1
prc.pragma.len == 0
prc
proc test(a, b: int): int {.gcsafe, raises: [], test1.} = 5
type hello = proc(a, b: int): int {.gcsafe, raises: [], test1.}