diff options
-rw-r--r-- | compiler/pragmas.nim | 4 | ||||
-rw-r--r-- | compiler/semstmts.nim | 3 | ||||
-rw-r--r-- | tests/errmsgs/tproper_stacktrace.nim | 18 |
3 files changed, 23 insertions, 2 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index bfb06e00a..bfb8e78eb 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -24,8 +24,8 @@ const wCompilerProc, wCore, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge, wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC, wAsmNoStackFrame, wError, wDiscardable, wNoInit, wCodegenDecl, - wGensym, wInject, wRaises, wTags, wLocks, wDelegator, wGcSafe, - wOverride, wConstructor, wExportNims, wUsed, wLiftLocals} + wGensym, wInject, wRaises, wTags, wLocks, wDelegator, wGcSafe, wOverride, + wConstructor, wExportNims, wUsed, wLiftLocals, wStacktrace, wLinetrace} converterPragmas* = procPragmas methodPragmas* = procPragmas+{wBase}-{wImportCpp} templatePragmas* = {wImmediate, wDeprecated, wError, wGensym, wInject, wDirty, diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 455e06e82..b4c327362 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1489,6 +1489,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, # before compiling the proc body, set as current the scope # where the proc was declared let oldScope = c.currentScope + let oldOptions = c.config.options #c.currentScope = s.scope pushOwner(c, s) openScope(c) @@ -1569,6 +1570,8 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, popOwner(c) pushOwner(c, s) s.options = c.config.options + c.config.options = oldOptions + if sfOverriden in s.flags or s.name.s[0] == '=': semOverride(c, s, n) if s.name.s[0] in {'.', '('}: if s.name.s in [".", ".()", ".="] and {destructor, dotOperators} * c.features == {}: diff --git a/tests/errmsgs/tproper_stacktrace.nim b/tests/errmsgs/tproper_stacktrace.nim index 4e5c5fbf8..134946651 100644 --- a/tests/errmsgs/tproper_stacktrace.nim +++ b/tests/errmsgs/tproper_stacktrace.nim @@ -119,5 +119,23 @@ when isMainModule: verifyStackTrace expectedStackTrace: foo() + block: + proc bar() {.stackTrace: off.} = + proc baz() = # Stack trace should be enabled + raiseTestException() + baz() + + proc foo() = + bar() + + const expectedStackTrace = """ + tproper_stacktrace.nim(139) tproper_stacktrace + tproper_stacktrace.nim(129) foo + tproper_stacktrace.nim(125) baz + tproper_stacktrace.nim(7) raiseTestException + """ + + verifyStackTrace expectedStackTrace: + foo() echo "ok" |