fixes #23233; Regression when using generic type with Table/OrderedTable (#23235)

fixes #23233

(cherry picked from commit 720021908d)
This commit is contained in:
ringabout
2024-01-20 03:37:16 +08:00
committed by narimiran
parent dbe9c724a0
commit 3a334e09ea
2 changed files with 22 additions and 2 deletions

View File

@@ -1247,7 +1247,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 i in 1..<lhs.len - 1:
let ff = rhs[i]

View File

@@ -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)