fixes #1919
This commit is contained in:
parent
d37ff0ab42
commit
fd10866ae3
2 changed files with 26 additions and 6 deletions
|
|
@ -609,12 +609,6 @@ proc addInheritedFieldsAux(c: PContext, check: var IntSet, pos: var int,
|
||||||
inc(pos)
|
inc(pos)
|
||||||
else: internalError(n.info, "addInheritedFieldsAux()")
|
else: internalError(n.info, "addInheritedFieldsAux()")
|
||||||
|
|
||||||
proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
|
|
||||||
obj: PType) =
|
|
||||||
if (sonsLen(obj) > 0) and (obj.sons[0] != nil):
|
|
||||||
addInheritedFields(c, check, pos, obj.sons[0])
|
|
||||||
addInheritedFieldsAux(c, check, pos, obj.n)
|
|
||||||
|
|
||||||
proc skipGenericInvokation(t: PType): PType {.inline.} =
|
proc skipGenericInvokation(t: PType): PType {.inline.} =
|
||||||
result = t
|
result = t
|
||||||
if result.kind == tyGenericInvokation:
|
if result.kind == tyGenericInvokation:
|
||||||
|
|
@ -622,6 +616,13 @@ proc skipGenericInvokation(t: PType): PType {.inline.} =
|
||||||
if result.kind == tyGenericBody:
|
if result.kind == tyGenericBody:
|
||||||
result = lastSon(result)
|
result = lastSon(result)
|
||||||
|
|
||||||
|
proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
|
||||||
|
obj: PType) =
|
||||||
|
assert obj.kind == tyObject
|
||||||
|
if (sonsLen(obj) > 0) and (obj.sons[0] != nil):
|
||||||
|
addInheritedFields(c, check, pos, obj.sons[0].skipGenericInvokation)
|
||||||
|
addInheritedFieldsAux(c, check, pos, obj.n)
|
||||||
|
|
||||||
proc semObjectNode(c: PContext, n: PNode, prev: PType): PType =
|
proc semObjectNode(c: PContext, n: PNode, prev: PType): PType =
|
||||||
if n.sonsLen == 0: return newConstraint(c, tyObject)
|
if n.sonsLen == 0: return newConstraint(c, tyObject)
|
||||||
var check = initIntSet()
|
var check = initIntSet()
|
||||||
|
|
|
||||||
19
tests/generics/tgeneric_inheritance.nim
Normal file
19
tests/generics/tgeneric_inheritance.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
discard """
|
||||||
|
output: '0.0'
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #1919
|
||||||
|
|
||||||
|
type
|
||||||
|
Base[M] = object of RootObj
|
||||||
|
a : M
|
||||||
|
|
||||||
|
Sub1[M] = object of Base[M]
|
||||||
|
b : int
|
||||||
|
|
||||||
|
Sub2[M] = object of Sub1[M]
|
||||||
|
c : int
|
||||||
|
|
||||||
|
var x: Sub2[float]
|
||||||
|
|
||||||
|
echo x.a
|
||||||
Loading…
Add table
Add a link
Reference in a new issue