line pragma

The line pragma can be used to affect line information of the annotated statement, as seen in stack backtraces:

  1. template myassert*(cond: untyped, msg = "") =
  2. if not cond:
  3. # change run-time line information of the 'raise' statement:
  4. {.line: instantiationInfo().}:
  5. raise newException(AssertionDefect, msg)

If the line pragma is used with a parameter, the parameter needs to be a tuple[filename: string, line: int]. If it is used without a parameter, system.instantiationInfo() is used.