Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Sep 25, 2024
1 parent 75a0083 commit 4667bc2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,7 @@ proc implicitPragmas*(c: PContext, sym: PSym, info: TLineInfo,
internalError(c.config, info, "implicitPragmas")
inc i
popInfoContext(c.config)
if sym.kind in routineKinds and sym.ast != nil and
not (sym.kind == skTemplate and sfGenSym in sym.flags):
if sym.kind in routineKinds and sym.ast != nil:
mergePragmas(sym.ast, o)

if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:
Expand Down
2 changes: 1 addition & 1 deletion compiler/sem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym,
# c.evalContext = c.createEvalContext(emStatic)
result = evalMacroCall(c.module, c.idgen, c.graph, c.templInstCounter, n, nOrig, sym)
if efNoSemCheck notin flags:
result = semAfterMacroCall(c, n, result, sym, flags, expectedType)
result = semAfterMacroCall(c, n, result, sym, flags+{efNoEvalTemplImplicitPragmas}, expectedType)
if c.config.macrosToExpand.hasKey(sym.name.s):
message(c.config, nOrig.info, hintExpandMacro, renderTree(result))
result = wrapInComesFrom(nOrig.info, sym, result)
Expand Down
1 change: 1 addition & 0 deletions compiler/semdata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type
efTypeAllowed # typeAllowed will be called after
efWantNoDefaults
efAllowSymChoice # symchoice node should not be resolved
efNoEvalTemplImplicitPragmas

TExprFlags* = set[TExprFlag]

Expand Down
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3526,7 +3526,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType
of nkMethodDef: result = semMethod(c, n)
of nkConverterDef: result = semConverterDef(c, n)
of nkMacroDef: result = semMacroDef(c, n)
of nkTemplateDef: result = semTemplateDef(c, n)
of nkTemplateDef: result = semTemplateDef(c, n, flags)
of nkImportStmt:
# this particular way allows 'import' in a 'compiles' context so that
# template canImport(x): bool =
Expand Down
5 changes: 3 additions & 2 deletions compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ proc semTemplBodyDirty(c: var TemplCtx, n: PNode): PNode =
# in semstmts.nim:
proc semProcAnnotation(c: PContext, prc: PNode; validPragmas: TSpecialWords): PNode

proc semTemplateDef(c: PContext, n: PNode): PNode =
proc semTemplateDef(c: PContext, n: PNode; flags: TExprFlags = {}): PNode =
result = semProcAnnotation(c, n, templatePragmas)
if result != nil: return result
result = n
Expand Down Expand Up @@ -701,7 +701,8 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
s.ast = n

pragmaCallable(c, s, n, templatePragmas)
implicitPragmas(c, s, n.info, templatePragmas)
if efNoEvalTemplImplicitPragmas notin flags:
implicitPragmas(c, s, n.info, templatePragmas)

setGenericParamsMisc(c, n)
# process parameters:
Expand Down

0 comments on commit 4667bc2

Please sign in to comment.