mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
process non-language pragma nodes in generics (#24254)
fixes #18649, refs #24183
Same as in #24183 for templates, we now process pragma nodes in generics
so that macro symbols are captured and the pragma arguments are checked,
but ignoring language pragma keywords.
A difference is that we cannot process call nodes as is, we have to
process their children individually so that the early untyped
macro/template instantiation in generics does not kick in.
(cherry picked from commit d72b848d17)
This commit is contained in:
3
tests/generics/mpragma1.nim
Normal file
3
tests/generics/mpragma1.nim
Normal file
@@ -0,0 +1,3 @@
|
||||
macro aMacro*(u:untyped):untyped =
|
||||
echo "in macro"
|
||||
result = u
|
||||
6
tests/generics/mpragma2.nim
Normal file
6
tests/generics/mpragma2.nim
Normal file
@@ -0,0 +1,6 @@
|
||||
import mpragma1
|
||||
proc p*[T]() =
|
||||
proc inner() {.aMacro.} =
|
||||
discard
|
||||
inner()
|
||||
discard
|
||||
10
tests/generics/tpragma.nim
Normal file
10
tests/generics/tpragma.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
discard """
|
||||
nimout: '''
|
||||
in macro
|
||||
'''
|
||||
"""
|
||||
|
||||
# issue #18649
|
||||
|
||||
import mpragma2
|
||||
p[string]()
|
||||
Reference in New Issue
Block a user