fixes #3973
This commit is contained in:
parent
5757ad858c
commit
6e53300f83
3 changed files with 35 additions and 3 deletions
|
|
@ -10,7 +10,9 @@
|
||||||
## This file implements the new evaluation engine for Nim code.
|
## This file implements the new evaluation engine for Nim code.
|
||||||
## An instruction is 1-3 int32s in memory, it is a register based VM.
|
## An instruction is 1-3 int32s in memory, it is a register based VM.
|
||||||
|
|
||||||
const debugEchoCode = false
|
const
|
||||||
|
debugEchoCode = false
|
||||||
|
traceCode = debugEchoCode
|
||||||
|
|
||||||
import ast except getstr
|
import ast except getstr
|
||||||
|
|
||||||
|
|
@ -404,7 +406,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
let instr = c.code[pc]
|
let instr = c.code[pc]
|
||||||
let ra = instr.regA
|
let ra = instr.regA
|
||||||
#if c.traceActive:
|
#if c.traceActive:
|
||||||
#echo "PC ", pc, " ", c.code[pc].opcode, " ra ", ra, " rb ", instr.regB, " rc ", instr.regC
|
when traceCode:
|
||||||
|
echo "PC ", pc, " ", c.code[pc].opcode, " ra ", ra, " rb ", instr.regB, " rc ", instr.regC
|
||||||
# message(c.debug[pc], warnUser, "Trace")
|
# message(c.debug[pc], warnUser, "Trace")
|
||||||
|
|
||||||
case instr.opcode
|
case instr.opcode
|
||||||
|
|
|
||||||
|
|
@ -1447,12 +1447,12 @@ proc getNullValue(typ: PType, info: TLineInfo): PNode =
|
||||||
of tyObject:
|
of tyObject:
|
||||||
result = newNodeIT(nkObjConstr, info, t)
|
result = newNodeIT(nkObjConstr, info, t)
|
||||||
result.add(newNodeIT(nkEmpty, info, t))
|
result.add(newNodeIT(nkEmpty, info, t))
|
||||||
getNullValueAux(t.n, result)
|
|
||||||
# initialize inherited fields:
|
# initialize inherited fields:
|
||||||
var base = t.sons[0]
|
var base = t.sons[0]
|
||||||
while base != nil:
|
while base != nil:
|
||||||
getNullValueAux(skipTypes(base, skipPtrs).n, result)
|
getNullValueAux(skipTypes(base, skipPtrs).n, result)
|
||||||
base = base.sons[0]
|
base = base.sons[0]
|
||||||
|
getNullValueAux(t.n, result)
|
||||||
of tyArray, tyArrayConstr:
|
of tyArray, tyArrayConstr:
|
||||||
result = newNodeIT(nkBracket, info, t)
|
result = newNodeIT(nkBracket, info, t)
|
||||||
for i in countup(0, int(lengthOrd(t)) - 1):
|
for i in countup(0, int(lengthOrd(t)) - 1):
|
||||||
|
|
|
||||||
29
tests/vm/tinheritance.nim
Normal file
29
tests/vm/tinheritance.nim
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
discard """
|
||||||
|
msg: '''Hello fred , managed by sally
|
||||||
|
Hello sally , managed by bob'''
|
||||||
|
"""
|
||||||
|
# bug #3973
|
||||||
|
|
||||||
|
type
|
||||||
|
EmployeeCode = enum
|
||||||
|
ecCode1,
|
||||||
|
ecCode2
|
||||||
|
|
||||||
|
Person* = object of RootObj
|
||||||
|
name* : string
|
||||||
|
last_name*: string
|
||||||
|
|
||||||
|
Employee* = object of Person
|
||||||
|
empl_code* : EmployeeCode
|
||||||
|
mgr_name* : string
|
||||||
|
|
||||||
|
proc test() =
|
||||||
|
var
|
||||||
|
empl1 = Employee(name: "fred", last_name: "smith", mgr_name: "sally", empl_code: ecCode1)
|
||||||
|
empl2 = Employee(name: "sally", last_name: "jones", mgr_name: "bob", empl_code: ecCode2)
|
||||||
|
|
||||||
|
echo "Hello ", empl1.name, " , managed by ", empl1.mgr_name
|
||||||
|
echo "Hello ", empl2.name, " , managed by ", empl2.mgr_name
|
||||||
|
|
||||||
|
static:
|
||||||
|
test()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue