diff options
-rw-r--r-- | compiler/semexprs.nim | 2 | ||||
-rw-r--r-- | tests/tuples/tgeneric_tuple2.nim | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 781efb891..60a1fd5b2 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -456,7 +456,7 @@ proc changeType(n: PNode, newType: PType, check: bool) = internalError(m.info, "changeType(): invalid tuple constr") return if tup.n != nil: - var f = getSymFromList(newType.n, m.sym.name) + var f = getSymFromList(tup.n, m.sym.name) if f == nil: internalError(m.info, "changeType(): invalid identifier") return diff --git a/tests/tuples/tgeneric_tuple2.nim b/tests/tuples/tgeneric_tuple2.nim new file mode 100644 index 000000000..c0c292388 --- /dev/null +++ b/tests/tuples/tgeneric_tuple2.nim @@ -0,0 +1,17 @@ + +# bug #2369 + +type HashedElem[T] = tuple[num: int, storedVal: ref T] + +proc append[T](tab: var seq[HashedElem[T]], n: int, val: ref T) = + #tab.add((num: n, storedVal: val)) + var he: HashedElem[T] = (num: n, storedVal: val) + #tab.add(he) + +var g: seq[HashedElem[int]] = @[] + +proc foo() = + var x: ref int + new(x) + x[] = 77 + g.append(44, x) |