fixes #25796; fixes procParamTypeRel to ensure backend type consistency

This commit is contained in:
ringabout
2026-05-07 20:27:24 +08:00
parent f0077a12b2
commit a353052d07
2 changed files with 32 additions and 1 deletions

View File

@@ -791,8 +791,12 @@ proc procParamTypeRel(c: var TCandidate; f, a: PType): TTypeRelation =
# different C types (size_t vs unsigned long long).
let fCheck = concreteType(c, f)
let aCheck = concreteType(c, a)
# Notes that `result` is requal, now
# we checks whether they have the same backend type
if fCheck != nil and aCheck != nil and
not sameBackendTypePickyAliases(fCheck, aCheck):
not sameBackendTypePickyAliases(
fCheck.skipTypes({tyVar, tyLent, tySink, tyOwned}),
aCheck.skipTypes({tyVar, tyLent, tySink, tyOwned})):
result = isNone
if result <= isSubrange or inconsistentVarTypes(f, a):

View File

@@ -29,3 +29,30 @@ block tnestprc:
result = x + y
result = add(x, 3)
doAssert Add3(7) == 10
block:
type A = object
c: int
type H = proc(): lent A {.nimcall.}
const u = A(c: 0)
proc e(T: typedesc): lent A = u
proc y(T: typedesc): H =
proc(): lent A {.nimcall.} = T.e
discard y(int)
block:
type A = object
c: int
type H = proc(): lent A {.nimcall.}
let u = A(c: 0)
proc y(_: int | int): H =
proc(): lent A {.nimcall.} = u
discard y(0)
block:
type A = object
c: int
type H = proc(): lent A {.nimcall.}
let u = A()
let _: H = proc(): lent A {.nimcall.} = u