mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
Fix: don't track Defect in proc effect compatibility (#22037)
(cherry picked from commit a4f9413a65)
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user