summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-01-20 03:37:16 +0800
committerGitHub <noreply@github.com>2024-01-19 20:37:16 +0100
commit720021908db1f6622c1ebcdad60dff5c2740a80b (patch)
treeeeeda89240edd7e88174c8ecab6d7c296ae1f064
parent1855f67503e6c541f3d8c38c3ec28c0fbb02be1a (diff)
downloadNim-720021908db1f6622c1ebcdad60dff5c2740a80b.tar.gz
fixes #23233; Regression when using generic type with Table/OrderedTable (#23235)
fixes #23233
-rw-r--r--compiler/types.nim2
-rw-r--r--tests/generics/tgeneric0.nim22
2 files changed, 22 insertions, 2 deletions
diff --git a/compiler/types.nim b/compiler/types.nim
index 8c447ddbf..372637827 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -1234,7 +1234,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
     let
       lhs = x.skipGenericAlias
       rhs = y.skipGenericAlias
-    if rhs.kind != tyGenericInst or lhs.base != rhs.base:
+    if rhs.kind != tyGenericInst or lhs.base != rhs.base or rhs.kidsLen != lhs.kidsLen:
       return false
     for ff, aa in underspecifiedPairs(rhs, lhs, 1, -1):
       if not sameTypeAux(ff, aa, c): return false
diff --git a/tests/generics/tgeneric0.nim b/tests/generics/tgeneric0.nim
index b5e1c4bb4..e0b61a58d 100644
--- a/tests/generics/tgeneric0.nim
+++ b/tests/generics/tgeneric0.nim
@@ -9,7 +9,7 @@ float32
 """
 
 
-import tables
+import std/tables
 
 
 block tgeneric0:
@@ -166,3 +166,23 @@ type
 # bug #8295
 var x = AtomicContainer[int]()
 doAssert (ptr Block[int])(x.b) == nil
+
+
+# bug #23233
+type
+  JsonObjectType*[T: string or uint64] = Table[string, JsonValueRef[T]]
+
+  JsonValueRef*[T: string or uint64] = object
+    objVal*: JsonObjectType[T]
+
+proc scanValue[K](val: var K) =
+  var map: JsonObjectType[K.T]
+  var newVal: K
+  map["one"] = newVal
+
+block:
+  var a: JsonValueRef[uint64]
+  scanValue(a)
+
+  var b: JsonValueRef[string]
+  scanValue(b)