Skip to content

nim c --gc:arc --exceptions:{setjmp,goto} incorrectly handles raise; nim cpp --gc:arc is ok #13070

Closed
@timotheecour

Description

@timotheecour

nim c --gc:arc --exceptions:{setjmp,goto} incorrectly handles raise; nim cpp --gc:arc is ok

Example

  type MyExcept = object of CatchableError
  proc gun()=
    try:
      raise newException(MyExcept, "some msg")
    except Exception as e:
      echo "caught in gun"
      raise e

  proc fun()=
    try:
      gun()
    except Exception as e:
      echo "caught in fun"
      echo ("caught", e.msg, e.name)
    finally:
      echo "in finally"
  fun()

Current Output

nim c --gc:arc --exceptions:setjmp main.nim
nim c --gc:arc --exceptions:goto main.nim
in finally
/Users/timothee/git_clone/nim/timn/tests/nim/all/t0900.nim(74) t0900
/Users/timothee/git_clone/nim/timn/tests/nim/all/t0900.nim(68) fun
/Users/timothee/git_clone/nim/timn/tests/nim/all/t0900.nim(61) gun
Error: unhandled exception: some msg [MyExcept]

Expected Output

nim c main.nim
nim cpp main.nim
nim cpp --gc:arc main.nim
caught in gun
caught in fun
("caught", "some msg", "MyExcept")
in finally

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions