fixes #23765; Method calling proc with return value overlapping declared generic type generates invalid C

This commit is contained in:
ringabout
2026-05-06 21:33:46 +08:00
parent cbe02aa9de
commit 065f46afa8
3 changed files with 20 additions and 2 deletions

View File

@@ -81,7 +81,8 @@ proc sameInstantiation(a, b: TInstantiation): bool =
if not compareTypes(a.concreteTypes[i], b.concreteTypes[i],
flags = {ExactTypeDescValues,
ExactGcSafety,
PickyCAliases}): return
PickyCAliases,
PickyBackendAliases}): return
result = true
else:
result = false

View File

@@ -52,7 +52,8 @@ proc searchInstTypes*(g: ModuleGraph; key: PType): PType =
for j in FirstGenericParamAt..<key.kidsLen:
# XXX sameType is not really correct for nested generics?
if not compareTypes(inst[j], key[j],
flags = {ExactGenericParams, PickyCAliases}):
flags = {ExactGenericParams, PickyCAliases,
PickyBackendAliases}):
break matchType
return inst

View File

@@ -75,3 +75,19 @@ block: # importc type inheritance
doAssert(cast[cint](b) == 123)
var c = foo(b)
doAssert(cast[cint](c) == 123)
# bug #23765
type
X11[T, E] = object
m: T
B = X11[culonglong, cstring]
S = ref object of RootObj
proc j[T, E](m: X11[T, E]): T = discard
proc n(T: typedesc[SomeUnsignedInt]): X11[T, cstring] = discard
method call(client: S): uint64 {.base.} =
discard j(n(uint64))
var s = S()
discard s.call()