mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 11:24:08 +00:00
bugfix: 'error' statement pragma works as expected again
This commit is contained in:
@@ -26,7 +26,7 @@ const
|
||||
wNoStackFrame, wError, wDiscardable, wNoInit}
|
||||
converterPragmas* = procPragmas
|
||||
methodPragmas* = procPragmas
|
||||
templatePragmas* = {wImmediate}
|
||||
templatePragmas* = {wImmediate, wDeprecated, wError}
|
||||
macroPragmas* = {FirstCallConv..LastCallConv, wImmediate, wImportc, wExportc,
|
||||
wNodecl, wMagic, wNosideEffect, wCompilerProc, wDeprecated, wExtern,
|
||||
wImportcpp, wImportobjc, wError, wDiscardable}
|
||||
@@ -560,10 +560,14 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||
of wHint: Message(it.info, hintUser, expectStrLit(c, it))
|
||||
of wWarning: Message(it.info, warnUser, expectStrLit(c, it))
|
||||
of wError:
|
||||
if sym != nil:
|
||||
if sym != nil and sym.isRoutine:
|
||||
# This is subtle but correct: the error *statement* is only
|
||||
# allowed for top level statements. Seems to be easier than
|
||||
# distinguishing properly between
|
||||
# ``proc p() {.error}`` and ``proc p() = {.error: "msg".}``
|
||||
noVal(it)
|
||||
incl(sym.flags, sfError)
|
||||
else:
|
||||
else:
|
||||
LocalError(it.info, errUser, expectStrLit(c, it))
|
||||
of wFatal: Fatal(it.info, errUser, expectStrLit(c, it))
|
||||
of wDefine: processDefine(c, it)
|
||||
@@ -609,12 +613,12 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||
else: invalidPragma(it)
|
||||
else: invalidPragma(it)
|
||||
else: processNote(c, it)
|
||||
if (sym != nil) and (sym.kind != skModule):
|
||||
if (lfExportLib in sym.loc.flags) and not (sfExportc in sym.flags):
|
||||
if sym != nil and sym.kind != skModule:
|
||||
if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:
|
||||
LocalError(n.info, errDynlibRequiresExportc)
|
||||
var lib = POptionEntry(c.optionstack.tail).dynlib
|
||||
if ({lfDynamicLib, lfHeader} * sym.loc.flags == {}) and
|
||||
(sfImportc in sym.flags) and (lib != nil):
|
||||
if {lfDynamicLib, lfHeader} * sym.loc.flags == {} and
|
||||
sfImportc in sym.flags and lib != nil:
|
||||
incl(sym.loc.flags, lfDynamicLib)
|
||||
addToLib(lib, sym)
|
||||
if sym.loc.r == nil: sym.loc.r = toRope(sym.name.s)
|
||||
|
||||
1
todo.txt
1
todo.txt
@@ -44,7 +44,6 @@ Bugs
|
||||
- bug: stress testing basic method example (eval example)
|
||||
without ``-d:release`` leaks memory?
|
||||
- bug: object {.pure, final.} does not work again!
|
||||
- bug: {.error: "msg".} produces invalid pragma message
|
||||
- bug: pragma statements in combination with symbol files are evaluated twice
|
||||
but this can lead to compilation errors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user