fixes #10033 [backport]
This commit is contained in:
parent
2539363851
commit
bdb67201b2
2 changed files with 26 additions and 3 deletions
|
|
@ -970,9 +970,9 @@ proc genTypeInfoAux(m: BModule, typ, origType: PType, name: Rope;
|
||||||
|
|
||||||
proc discriminatorTableName(m: BModule, objtype: PType, d: PSym): Rope =
|
proc discriminatorTableName(m: BModule, objtype: PType, d: PSym): Rope =
|
||||||
# bugfix: we need to search the type that contains the discriminator:
|
# bugfix: we need to search the type that contains the discriminator:
|
||||||
var objtype = objtype
|
var objtype = objtype.skipTypes(abstractPtrs)
|
||||||
while lookupInRecord(objtype.n, d.name) == nil:
|
while lookupInRecord(objtype.n, d.name) == nil:
|
||||||
objtype = objtype.sons[0]
|
objtype = objtype.sons[0].skipTypes(abstractPtrs)
|
||||||
if objtype.sym == nil:
|
if objtype.sym == nil:
|
||||||
internalError(m.config, d.info, "anonymous obj with discriminator")
|
internalError(m.config, d.info, "anonymous obj with discriminator")
|
||||||
result = "NimDT_$1_$2" % [rope($hashType(objtype)), rope(d.name.s.mangle)]
|
result = "NimDT_$1_$2" % [rope($hashType(objtype)), rope(d.name.s.mangle)]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''some(str), some(5), none
|
output: '''some(str), some(5), none
|
||||||
some(5!)
|
some(5!)
|
||||||
some(10)'''
|
some(10)
|
||||||
|
34'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import strutils
|
import strutils
|
||||||
|
|
@ -45,3 +46,25 @@ let a3 = intOrString(some(5))
|
||||||
#echo a1
|
#echo a1
|
||||||
echo a2
|
echo a2
|
||||||
echo a3
|
echo a3
|
||||||
|
|
||||||
|
|
||||||
|
# bug #10033
|
||||||
|
|
||||||
|
type
|
||||||
|
Token = enum
|
||||||
|
Int,
|
||||||
|
Float
|
||||||
|
|
||||||
|
Base = ref object of RootObj
|
||||||
|
case token: Token
|
||||||
|
of Int:
|
||||||
|
bInt: int
|
||||||
|
of Float:
|
||||||
|
bFloat: float
|
||||||
|
|
||||||
|
Child = ref object of Base
|
||||||
|
|
||||||
|
let c = new Child
|
||||||
|
c.token = Int
|
||||||
|
c.bInt = 34
|
||||||
|
echo c.bInt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue