diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-10-27 15:37:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-27 15:37:34 +0200 |
commit | cacbf8b32c7b910eeb6b8b5d37adf2a7dd2f343c (patch) | |
tree | faddd5fb0ea8009db010f75c8bdff642ab5e4c2e /compiler/vm.nim | |
parent | 38ad7400fa4ecc475b587456770e4d981dc9d037 (diff) | |
parent | 74c6500a30b99fde9af5d17a87723dcf18309964 (diff) | |
download | Nim-cacbf8b32c7b910eeb6b8b5d37adf2a7dd2f343c.tar.gz |
Merge pull request #4963 from jangko/macro_error_improvement
Macro.error improvement fixes #4915
Diffstat (limited to 'compiler/vm.nim')
-rw-r--r-- | compiler/vm.nim | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim index be522ced0..c4e8df90e 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -76,12 +76,13 @@ proc stackTraceAux(c: PCtx; x: PStackFrame; pc: int; recursionLimit=100) = msgWriteln(s) proc stackTrace(c: PCtx, tos: PStackFrame, pc: int, - msg: TMsgKind, arg = "") = + msg: TMsgKind, arg = "", n: PNode = nil) = msgWriteln("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.debug[pc], msg, arg) - else: localError(c.debug[pc], msg, arg) + let lineInfo = if n == nil: c.debug[pc] else: n.info + if c.mode == emRepl: globalError(lineInfo, msg, arg) + else: localError(lineInfo, msg, arg) proc bailOut(c: PCtx; tos: PStackFrame) = stackTrace(c, tos, c.exceptionInstr, errUnhandledExceptionX, @@ -1245,7 +1246,10 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = regs[rc].node.strVal, regs[rd].node.strVal, c.debug[pc]) of opcNError: - stackTrace(c, tos, pc, errUser, regs[ra].node.strVal) + decodeB(rkNode) + let a = regs[ra].node + let b = regs[rb].node + stackTrace(c, tos, pc, errUser, a.strVal, if b.kind == nkNilLit: nil else: b) of opcNWarning: message(c.debug[pc], warnUser, regs[ra].node.strVal) of opcNHint: |