You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var counter =0typeLease=object
initialized: boolproc`=destroy`(v: varLease) =if v.initialized:
dec counter
proclease(): Lease=inc counter
Lease(initialized: true)
typeFail=object
initialized: boolFailError=objectofCatchableErrorproc`=destroy`(v: varFail) =if v.initialized:
raisenewException(FailError, "operation failed")
procinitFail(): Fail=Fail(initialized: true)
procleaky() =let a =lease()
let b =initFail()
procmain() =doAssert counter ==0, "counter is not zero at start"try:
leaky()
exceptFailError:
discard"not an issue"doAssert counter ==0, "the lease should be released"main()
Actual Output
fatal.nim(48) sysFatal
Error: unhandled exception: test.nim(40, 12) `counter == 0` the lease should be released [AssertionDefect]
Expected Output
No output
Possible Solution
Force Defect to be the only allowed exception type raised by destructors
Generates code to continue cleanup even after exception, then raises the exception stack afterwards
The text was updated successfully, but these errors were encountered:
Example
Actual Output
Expected Output
No output
Possible Solution
Defect
to be the only allowed exception type raised by destructorsThe text was updated successfully, but these errors were encountered: