diff --git a/compiler/msgs.nim b/compiler/msgs.nim index aecaaf405..a5953237e 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -13,7 +13,7 @@ import import std/private/miscdollars import strutils2 -type InstantiationInfo = typeof(instantiationInfo()) +type InstantiationInfo* = typeof(instantiationInfo()) template instLoc(): InstantiationInfo = instantiationInfo(-2, fullPaths = true) template flushDot(conf, stdorr) = @@ -385,7 +385,7 @@ proc getMessageStr(msg: TMsgKind, arg: string): string = result = msgKindToString(msg) % [arg] type - TErrorHandling = enum doNothing, doAbort, doRaise + TErrorHandling* = enum doNothing, doAbort, doRaise proc log*(s: string) = var f: File @@ -485,7 +485,7 @@ proc formatMsg*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string): s else: ErrorTitle conf.toFileLineCol(info) & " " & title & getMessageStr(msg, arg) -proc liMessage(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string, +proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string, eh: TErrorHandling, info2: InstantiationInfo, isRaw = false) {.noinline.} = var title: string diff --git a/compiler/vm.nim b/compiler/vm.nim index c15f9e268..9b76d7986 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -72,20 +72,18 @@ proc stackTraceAux(c: PCtx; x: PStackFrame; pc: int; recursionLimit=100) = msgWriteln(c.config, s) proc stackTraceImpl(c: PCtx, tos: PStackFrame, pc: int, - msg: string, lineInfo: TLineInfo) = + msg: string, lineInfo: TLineInfo, infoOrigin: InstantiationInfo) {.noinline.} = + # noinline to avoid code bloat msgWriteln(c.config, "stack trace: (most recent call last)") stackTraceAux(c, tos, pc) - # XXX test if we want 'globalError' for every mode - if c.mode == emRepl: globalError(c.config, lineInfo, msg) - else: localError(c.config, lineInfo, msg) + let action = if c.mode == emRepl: doRaise else: doNothing + # XXX test if we want 'globalError' for every mode + let lineInfo = if lineInfo == TLineInfo.default: c.debug[pc] else: lineInfo + liMessage(c.config, lineInfo, errGenerated, msg, action, infoOrigin) template stackTrace(c: PCtx, tos: PStackFrame, pc: int, - msg: string, lineInfo: TLineInfo) = - stackTraceImpl(c, tos, pc, msg, lineInfo) - return - -template stackTrace(c: PCtx, tos: PStackFrame, pc: int, msg: string) = - stackTraceImpl(c, tos, pc, msg, c.debug[pc]) + msg: string, lineInfo: TLineInfo = TLineInfo.default) = + stackTraceImpl(c, tos, pc, msg, lineInfo, instantiationInfo(-2, fullPaths = true)) return proc bailOut(c: PCtx; tos: PStackFrame) =