Skip to content

Commit 4667bc2

Browse files
committed
fixes
1 parent 75a0083 commit 4667bc2

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

compiler/pragmas.nim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,7 @@ proc implicitPragmas*(c: PContext, sym: PSym, info: TLineInfo,
13571357
internalError(c.config, info, "implicitPragmas")
13581358
inc i
13591359
popInfoContext(c.config)
1360-
if sym.kind in routineKinds and sym.ast != nil and
1361-
not (sym.kind == skTemplate and sfGenSym in sym.flags):
1360+
if sym.kind in routineKinds and sym.ast != nil:
13621361
mergePragmas(sym.ast, o)
13631362

13641363
if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:

compiler/sem.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym,
520520
# c.evalContext = c.createEvalContext(emStatic)
521521
result = evalMacroCall(c.module, c.idgen, c.graph, c.templInstCounter, n, nOrig, sym)
522522
if efNoSemCheck notin flags:
523-
result = semAfterMacroCall(c, n, result, sym, flags, expectedType)
523+
result = semAfterMacroCall(c, n, result, sym, flags+{efNoEvalTemplImplicitPragmas}, expectedType)
524524
if c.config.macrosToExpand.hasKey(sym.name.s):
525525
message(c.config, nOrig.info, hintExpandMacro, renderTree(result))
526526
result = wrapInComesFrom(nOrig.info, sym, result)

compiler/semdata.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type
7676
efTypeAllowed # typeAllowed will be called after
7777
efWantNoDefaults
7878
efAllowSymChoice # symchoice node should not be resolved
79+
efNoEvalTemplImplicitPragmas
7980

8081
TExprFlags* = set[TExprFlag]
8182

compiler/semexprs.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType
35263526
of nkMethodDef: result = semMethod(c, n)
35273527
of nkConverterDef: result = semConverterDef(c, n)
35283528
of nkMacroDef: result = semMacroDef(c, n)
3529-
of nkTemplateDef: result = semTemplateDef(c, n)
3529+
of nkTemplateDef: result = semTemplateDef(c, n, flags)
35303530
of nkImportStmt:
35313531
# this particular way allows 'import' in a 'compiles' context so that
35323532
# template canImport(x): bool =

compiler/semtempl.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ proc semTemplBodyDirty(c: var TemplCtx, n: PNode): PNode =
672672
# in semstmts.nim:
673673
proc semProcAnnotation(c: PContext, prc: PNode; validPragmas: TSpecialWords): PNode
674674

675-
proc semTemplateDef(c: PContext, n: PNode): PNode =
675+
proc semTemplateDef(c: PContext, n: PNode; flags: TExprFlags = {}): PNode =
676676
result = semProcAnnotation(c, n, templatePragmas)
677677
if result != nil: return result
678678
result = n
@@ -701,7 +701,8 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
701701
s.ast = n
702702

703703
pragmaCallable(c, s, n, templatePragmas)
704-
implicitPragmas(c, s, n.info, templatePragmas)
704+
if efNoEvalTemplImplicitPragmas notin flags:
705+
implicitPragmas(c, s, n.info, templatePragmas)
705706

706707
setGenericParamsMisc(c, n)
707708
# process parameters:

0 commit comments

Comments
 (0)