hintMsgOrigin now works in VM code (#14678)

* `hintMsgOrigin` now works in VM code

* remove a simplification for now
This commit is contained in:
Timothee Cour
2020-06-15 23:49:57 -07:00
committed by GitHub
parent faedb14a16
commit de5cde473a
2 changed files with 11 additions and 13 deletions

View File

@@ -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

View File

@@ -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) =