mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-15 07:43:26 +00:00
fixes #1684
This commit is contained in:
@@ -936,6 +936,10 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||
else:
|
||||
if f.sonsLen > 0 and f.sons[0].kind != tyNone:
|
||||
result = typeRel(c, f.lastSon, a)
|
||||
if doBind and result notin {isNone, isGeneric}:
|
||||
let concrete = concreteType(c, a)
|
||||
if concrete == nil: return isNone
|
||||
put(c.bindings, f, concrete)
|
||||
else:
|
||||
result = isGeneric
|
||||
|
||||
|
||||
13
tests/generics/tsubtypeconstraint.nim
Normal file
13
tests/generics/tsubtypeconstraint.nim
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# bug #1684
|
||||
type
|
||||
BaseType {.inheritable pure.} = object
|
||||
idx: int
|
||||
|
||||
DerivedType* {.final pure.} = object of BaseType
|
||||
|
||||
proc index*[Toohoo: BaseType](h: Toohoo): int {.inline.} = h.idx
|
||||
proc newDerived(idx: int): DerivedType {.inline.} = DerivedType(idx: idx)
|
||||
|
||||
let d = newDerived(2)
|
||||
assert(d.index == 2)
|
||||
Reference in New Issue
Block a user