fix #13524 astToStr now works inside generics (#13681)

This commit is contained in:
Timothee Cour
2020-03-18 05:43:32 -07:00
committed by GitHub
parent a87062393a
commit ed263e174e
2 changed files with 7 additions and 1 deletions

View File

@@ -226,7 +226,7 @@ proc semGenericStmt(c: PContext, n: PNode,
var mixinContext = false
if s != nil:
incl(s.flags, sfUsed)
mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles}
mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles, mAstToStr}
let sc = symChoice(c, fn, s, if s.isMixedIn: scForceOpen else: scOpen)
case s.kind
of skMacro:

View File

@@ -0,0 +1,6 @@
# https://github.com/nim-lang/Nim/issues/13524
template fun(field): untyped = astToStr(field)
proc test1(): string = fun(nonexistant1)
proc test2[T](): string = fun(nonexistant2) # used to cause: Error: undeclared identifier: 'nonexistant2'
doAssert test1() == "nonexistant1"
doAssert test2[int]() == "nonexistant2"