From fc967cc7151665a21be035a22e9432b80feb0b90 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 12 Feb 2018 16:40:15 +0100 Subject: [PATCH] custom pragmas: proper error handling --- compiler/pragmas.nim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index d52d8b614a..4ed1cea24e 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -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: