Fix: don't track Defect in proc effect compatibility (#22037)

(cherry picked from commit a4f9413a65)
This commit is contained in:
Tanguy
2023-06-08 14:09:06 +02:00
committed by narimiran
parent 2b6797dc42
commit c50adf10d9
2 changed files with 19 additions and 1 deletions

View File

@@ -1394,6 +1394,19 @@ proc compatibleEffectsAux(se, re: PNode): bool =
return false
result = true
proc isDefectException*(t: PType): bool
proc compatibleExceptions(se, re: PNode): bool =
if re.isNil: return false
for r in items(re):
block search:
if isDefectException(r.typ):
break search
for s in items(se):
if safeInheritanceDiff(r.typ, s.typ) <= 0:
break search
return false
result = true
type
EffectsCompat* = enum
efCompat
@@ -1425,7 +1438,7 @@ proc compatibleEffects*(formal, actual: PType): EffectsCompat =
if not isNil(se) and se.kind != nkArgList:
# spec requires some exception or tag, but we don't know anything:
if real.len == 0: return efRaisesUnknown
let res = compatibleEffectsAux(se, real[exceptionEffects])
let res = compatibleExceptions(se, real[exceptionEffects])
if not res: return efRaisesDiffer
let st = spec[tagEffects]

View File

@@ -25,6 +25,11 @@ proc lier(): int {.raises: [IO2Error].} =
proc forw: int =
raise newException(IOError, "arg")
block:
proc someProc(t: string) {.raises: [Defect].} =
discard
let vh: proc(topic: string) {.raises: [].} = someProc
{.push raises: [Defect].}
type