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

No stack trace is printed when a proc in os/syncio module throw an exception at compile time #22558

Open demotomohiro opened 1 year ago

demotomohiro commented 1 year ago

Description

When procedures in os/syncio module failed and throw an exception at compile time, it doesn't print stack trace. So it is hard to find which procedure threw the exception.

For example: testvm.nim

static:
  writeFile("/nopermission", "")

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64] Compiled at 2023-08-25 Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 53d43e96716539d96e6a1e5f3926a3fe3a11e2dd active boot switches: -d:release

Current Output

$ nim c testvm.nim 
..................................................................................................................syncio.nim(868)          writeFile
Error: unhandled exception: cannot open: /nopermission [IOError]

Expected Output

testvm.nim(2) testvm
Nim/lib/std/syncio.nim(868) writeFile
Error: unhandled exception: cannot open: /nopermission [IOError]

Possible Solution

No response

Additional Information

No response

ringabout commented 1 year ago

A potential solution is to catch the exception in the vmops and use stacktrace like what is said in the https://github.com/timotheecour/Nim/issues/363 and https://github.com/nim-lang/Nim/pull/11955