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

This commit is contained in:
Tanguy
2023-06-08 14:09:06 +02:00
committed by GitHub
parent a8d0dda833
commit a4f9413a65
2 changed files with 19 additions and 1 deletions

View File

@@ -1434,6 +1434,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
proc hasIncompatibleEffect(se, re: PNode): bool =
if re.isNil: return false
for r in items(re):
@@ -1472,7 +1485,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

@@ -22,6 +22,11 @@ proc lier(): int {.raises: [IO2Error].} = #[tt.Hint
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