mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 20:04:18 +00:00
custom pragmas: proper error handling
This commit is contained in:
@@ -657,15 +657,16 @@ proc pragmaGuard(c: PContext; it: PNode; kind: TSymKind): PSym =
|
||||
result = qualifiedLookUp(c, n, {checkUndeclared})
|
||||
|
||||
proc semCustomPragma(c: PContext, n: PNode): PNode =
|
||||
assert(n.kind in nkPragmaCallKinds + {nkIdent})
|
||||
|
||||
if n.kind == nkIdent:
|
||||
result = newTree(nkCall, n)
|
||||
elif n.kind == nkExprColonExpr:
|
||||
# pragma: arg -> pragma(arg)
|
||||
result = newTree(nkCall, n[0], n[1])
|
||||
else:
|
||||
elif n.kind in nkPragmaCallKinds + {nkIdent}:
|
||||
result = n
|
||||
else:
|
||||
invalidPragma(n)
|
||||
return n
|
||||
|
||||
let r = c.semOverloadedCall(c, result, n, {skTemplate}, {})
|
||||
if r.isNil or sfCustomPragma notin r[0].sym.flags:
|
||||
|
||||
Reference in New Issue
Block a user