nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

Nimscript doesn't execute 'finally' after 'except' returns/breaks #10925

Open Wh1teDuke opened 5 years ago

Wh1teDuke commented 5 years ago

Test

# Nimscript file
var i = 0

proc testInc =
  try:      doAssert false
  except:   return
  finally:  inc(i)

testInc()
doAssert i == 1

Result

stack trace: (most recent call last)
Test.nims(9, 11)
[...]/Nim/lib/system/assertions.nim(27, 20) failedAssertImpl
[...]/Nim/lib/system/assertions.nim(20, 11) raiseAssert
[...]/Nim/lib/system/fatal.nim(37, 5) sysFatal
[...]/Nim/lib/system/fatal.nim(37, 5) Error: unhandled exception: [...]/Test.nims(9, 10) `i == 1`

Same behavior with a try inside a block and break inside except.


Nim Compiler Version 0.19.9 [Linux: i386]
Compiled at 2019-03-28
git hash: e904b3f952011ad9531b0923c2000398373af687
active boot switches: -d:release
Araq commented 5 years ago

Still an issue after our exception handling bugfixes.