Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An exception might exist after an except clause #18070

Open
alaviss opened this issue May 23, 2021 · 0 comments
Open

An exception might exist after an except clause #18070

alaviss opened this issue May 23, 2021 · 0 comments
Assignees

Comments

@alaviss
Copy link
Collaborator

alaviss commented May 23, 2021

An effect of this is that the exception will be logically "leaked" for the remainder of the program.

Reproducible with both exceptions:goto and exceptions:setjmp. Not reproducible with cpp exceptions.

Example

proc main() =
  try:
    try:
      raise newException(CatchableError, "something")
    except:
      raise newException(CatchableError, "something else")
  except:
    doAssert getCurrentExceptionMsg() == "something else"

  let msg = getCurrentExceptionMsg()
  doAssert msg == "", "expected empty string but got: " & $msg

main()

Current Output

in.nim(13)     in
in.nim(11)     main
assertions.nim(30) failedAssertImpl
assertions.nim(23) raiseAssert
fatal.nim(49) sysFatal
Error: unhandled exception: in.nim(11, 12) `msg == ""` expected empty string but got: something [AssertionDefect]

Expected Output

Successfully run

Additional Information

Found while evaluating exceptions semantics for implementation in CPS

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-05-23
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 61630c6aee56acf688c48c00f5a6711a59e79616
active boot switches: -d:release -d:nimUseLinenoise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment