Skip to content

Commit

Permalink
fixes nim-lang#11727 [backport]
Browse files Browse the repository at this point in the history
(cherry picked from commit 0996eb1)
  • Loading branch information
Araq authored and narimiran committed Dec 10, 2019
1 parent 299f1e9 commit 3f6a08d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions compiler/vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ type
ExceptionGotoUnhandled

proc findExceptionHandler(c: PCtx, f: PStackFrame, exc: PNode):
tuple[why: ExceptionGoto, where: int] =
tuple[why: ExceptionGoto, where: int] =
let raisedType = exc.typ.skipTypes(abstractPtrs)

while f.safePoints.len > 0:
Expand Down Expand Up @@ -1316,9 +1316,11 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
of opcQuit:
if c.mode in {emRepl, emStaticExpr, emStaticStmt}:
message(c.config, c.debug[pc], hintQuitCalled)
msgQuit(int8(toInt(getOrdValue(regs[ra].regToNode))))
msgQuit(int8(toInt(getOrdValue(regs[ra].regToNode, onError = toInt128(1)))))
else:
return TFullReg(kind: rkNone)
of opcInvalidField:
stackTrace(c, tos, pc, errFieldXNotFound & regs[ra].node.strVal)
of opcSetLenStr:
decodeB(rkNode)
#createStrKeepNode regs[ra]
Expand Down
2 changes: 1 addition & 1 deletion compiler/vmdef.nim
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type
opcContainsSet, opcRepr, opcSetLenStr, opcSetLenSeq,
opcIsNil, opcOf, opcIs,
opcSubStr, opcParseFloat, opcConv, opcCast,
opcQuit,
opcQuit, opcInvalidField,
opcNarrowS, opcNarrowU,
opcSignExtend,

Expand Down
9 changes: 7 additions & 2 deletions compiler/vmgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1717,8 +1717,13 @@ proc genCheckedObjAccessAux(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags
# If the check fails let the user know
let lab1 = c.xjmp(n, if negCheck: opcFJmp else: opcTJmp, rs)
c.freeTemp(rs)
# Not ideal but will do for the moment
c.gABC(n, opcQuit)
let strType = getSysType(c.graph, n.info, tyString)
var fieldNameRegister: TDest = c.getTemp(strType)
let strLit = newStrNode($accessExpr[1], accessExpr[1].info)
strLit.typ = strType
c.genLit(strLit, fieldNameRegister)
c.gABC(n, opcInvalidField, fieldNameRegister)
c.freeTemp(fieldNameRegister)
c.patch(lab1)

proc genCheckedObjAccess(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
Expand Down

0 comments on commit 3f6a08d

Please sign in to comment.