Fixed #18838 (#18841) [backport]

This commit is contained in:
Jason Beetham
2021-09-13 01:35:19 -06:00
committed by GitHub
parent 5d1608c976
commit 3f3e0fa303
2 changed files with 40 additions and 2 deletions

View File

@@ -344,7 +344,11 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
x = lookupTypeVar(cl, x)
if x != nil:
if header == t: header = instCopyType(cl, t)
header[i] = x
header[i] =
if x.kind == tyGenericInst:
t[i]
else:
x
propagateToOwner(header, x)
else:
propagateToOwner(header, x)

View File

@@ -1,6 +1,7 @@
block: # Replicates #18728
type
FlipFlop[A, B] = ref object
val: A
next: FlipFlop[B, A]
Trinary[A, B, C] = ref object
@@ -9,4 +10,37 @@ block: # Replicates #18728
assert typeof(FlipFlop[int, string]().next) is FlipFlop[string, int]
assert typeof(FlipFlop[string, int]().next) is FlipFlop[int, string]
assert typeof(Trinary[int, float, string]().next) is Trinary[float, string, int]
assert typeof(Trinary[int, float, string]().next.next) is Trinary[string, int, float]
assert typeof(Trinary[int, float, string]().next.next) is Trinary[string, int, float]
var a = FlipFlop[int, string](val: 100, next: FlipFlop[string, int](val: "Hello"))
assert a.val == 100
assert a.next.val == "Hello"
block: # 18838
type
DoublyLinkedNodeObj[T] = object
value: T
DoublyLinkedNode[T] = ref DoublyLinkedNodeObj[T]
Item[T] = ref object
link: DoublyLinkedNode[Item[T]]
Box = object
proc newDoublyLinkedNode[T](value: T): DoublyLinkedNode[T] =
new(result)
result.value = value
let link = newDoublyLinkedNode(Item[Box]())
import lists
block:
type
Box = object
Item[T] = ref object
link:DoublyLinkedNode[ Item[T] ]
ItemSimple = ref object
link:DoublyLinkedNode[ ItemSimple ]
let link = newDoublyLinkedNode( Item[Box]() )