This commit is contained in:
Andreas Rumpf
2018-10-26 01:25:06 +02:00
parent 5b97762787
commit 0c3e6735ac

View File

@@ -949,10 +949,10 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
recordPragma(c, it, "warning", s)
message(c.config, it.info, warnUser, s)
of wError:
if sym != nil and (sym.isRoutine or sym.kind == skType):
if sym != nil and (sym.isRoutine or sym.kind == skType) and wUsed in validPragmas:
# This is subtle but correct: the error *statement* is only
# allowed for top level statements. Seems to be easier than
# distinguishing properly between
# allowed when 'wUsed' is not in validPragmas. Here this is the easiest way to
# distinguish properly between
# ``proc p() {.error}`` and ``proc p() = {.error: "msg".}``
if it.kind in nkPragmaCallKinds: discard getStrLitNode(c, it)
incl(sym.flags, sfError)