mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
fixes #22902
(cherry picked from commit 95e5ad6927)
This commit is contained in:
@@ -809,7 +809,7 @@ proc searchForBorrowProc(c: PContext, startScope: PScope, fn: PSym): tuple[s: PS
|
||||
if resolved != nil:
|
||||
result.s = resolved[0].sym
|
||||
result.state = bsMatch
|
||||
if not compareTypes(result.s.typ[0], fn.typ[0], dcEqIgnoreDistinct):
|
||||
if not compareTypes(result.s.typ[0], fn.typ[0], dcEqIgnoreDistinct, {IgnoreFlags}):
|
||||
result.state = bsReturnNotMatch
|
||||
elif result.s.magic in {mArrPut, mArrGet}:
|
||||
# cannot borrow these magics for now
|
||||
|
||||
@@ -991,6 +991,7 @@ type
|
||||
ExactGcSafety
|
||||
AllowCommonBase
|
||||
PickyCAliases # be picky about the distinction between 'cint' and 'int32'
|
||||
IgnoreFlags # used for borrowed functions; ignores the tfVarIsPtr flag
|
||||
|
||||
TTypeCmpFlags* = set[TTypeCmpFlag]
|
||||
|
||||
@@ -1312,7 +1313,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||
cycleCheck()
|
||||
if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
|
||||
result = sameChildrenAux(a, b, c)
|
||||
if result:
|
||||
if result and IgnoreFlags notin c.flags:
|
||||
if IgnoreTupleFields in c.flags:
|
||||
result = a.flags * {tfVarIsPtr, tfIsOutParam} == b.flags * {tfVarIsPtr, tfIsOutParam}
|
||||
else:
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import std/tables
|
||||
|
||||
type
|
||||
Foo = distinct seq[int]
|
||||
Bar[N: static[int]] = distinct seq[int]
|
||||
@@ -46,3 +48,9 @@ proc `==`*(x, y: Fine): bool {.borrow.} =
|
||||
var x = Fine("1234")
|
||||
var y = Fine("1234")
|
||||
doAssert x == y
|
||||
|
||||
block: # bug #22902
|
||||
type
|
||||
DistinctTable = distinct Table[int, int]
|
||||
|
||||
proc `[]`(t: DistinctTable; key: int): lent int {.borrow.}
|
||||
|
||||
Reference in New Issue
Block a user