make json.to work with the more restricted case objects

This commit is contained in:
Araq 2019-05-27 15:33:17 +02:00 • committed by Andreas Rumpf
commit 383147f5cb
2 changed files with 14 additions and 17 deletions

View file

@ -224,14 +224,14 @@ proc selectBranch(discVal, L: int,
a: ptr array[0x7fff, ptr TNimNode]): ptr TNimNode =
result = a[L] # a[L] contains the ``else`` part (but may be nil)
if discVal <% L:
var x = a[discVal]
let x = a[discVal]
if x != nil: result = x
proc FieldDiscriminantCheck(oldDiscVal, newDiscVal: int,
a: ptr array[0x7fff, ptr TNimNode],
L: int) {.compilerProc.} =
var oldBranch = selectBranch(oldDiscVal, L, a)
var newBranch = selectBranch(newDiscVal, L, a)
let oldBranch = selectBranch(oldDiscVal, L, a)
let newBranch = selectBranch(newDiscVal, L, a)
when defined(nimOldCaseObjects):
if newBranch != oldBranch and oldDiscVal != 0:
sysFatal(FieldError, "assignment to discriminant changes object branch")