From 0aa623fcf7885d1879e88339267275374af3e9e2 Mon Sep 17 00:00:00 2001 From: araq Date: Fri, 29 May 2026 07:50:21 +0200 Subject: [PATCH] fixes #25830 --- compiler/sigmatch.nim | 6 +++++- compiler/types.nim | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index bf9c2d2050..7375a28262 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -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) + # `tfVarIsPtr` is an internal lowering artifact set during a proc's body + # analysis; a `proc` type literal's `var`/`lent` return never carries it, + # so `IgnoreFlags` keeps it from blocking matching `var T` against `var T`. + # The var/lent consistency itself is handled by `inconsistentVarTypes` below. if fCheck != nil and aCheck != nil and - not sameBackendTypePickyAliases(fCheck, aCheck): + not sameBackendTypePickyAliases(fCheck, aCheck, {IgnoreFlags}): result = isNone if result <= isSubrange or inconsistentVarTypes(f, a): diff --git a/compiler/types.nim b/compiler/types.nim index de24471e7d..f4c7e74bc5 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1069,9 +1069,10 @@ proc sameBackendTypeIgnoreRange*(x, y: PType): bool = c.cmp = dcEqIgnoreDistinct result = sameTypeAux(x, y, c) -proc sameBackendTypePickyAliases*(x, y: PType): bool = +proc sameBackendTypePickyAliases*(x, y: PType, flags: TTypeCmpFlags = {}): bool = var c = initSameTypeClosure() c.flags.incl {IgnoreTupleFields, IgnoreRangeShallow, PickyCAliases, PickyBackendAliases} + c.flags.incl flags c.cmp = dcEqIgnoreDistinct result = sameTypeAux(x, y, c)