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

Wrong stack trace when exception is raised in template #23620

Open
simonkrauter opened this issue May 16, 2024 · 1 comment
Open

Wrong stack trace when exception is raised in template #23620

simonkrauter opened this issue May 16, 2024 · 1 comment

Comments

@simonkrauter
Copy link
Contributor

Description

I found a case, where getStackTrace() returns the line number of the raise statement inside the template definition, instead of the line number of the template instantiation.

Test program:

type Severity = enum
  fatal
  regular

template raiseError*(severity: Severity) =
  if severity == fatal:
    raise newException(Defect, "error")

proc main() =
  try:
    raiseError(fatal)
  except:
    echo getCurrentException().getStackTrace()

main()

Note: Without the ìf statement it works correct.

Nim Version

Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-03-28
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: b47747d
active boot switches: -d:release

Current Output

main.nim(7)              main

Expected Output

main.nim(11)              main

Possible Solution

No response

Additional Information

No response

@rockcavera
Copy link
Contributor

@simonkrauter see this: https://nim-lang.org/docs/manual.html#pragmas-line-pragma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants