diff options
author | metagn <metagngn@gmail.com> | 2022-10-03 07:07:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-03 06:07:55 +0200 |
commit | 2cca38d33c50650d1606c6ec09c73af6b8b0c3c8 (patch) | |
tree | b4c3053dc221b84fa576efff2f04d41f48bbf148 /tests | |
parent | 81e7811e01b22518cb5e533cf75ed5dda0873415 (diff) | |
download | Nim-2cca38d33c50650d1606c6ec09c73af6b8b0c3c8.tar.gz |
pragma for sfCallsite instead of name check + better semantics, test (#20464)
* pragma for sfCallsite instead of name check at every template definition Not documented because it seems to be for internal use? Should also make it possible to make comparisons and setops imports, but this doesn't have to be done. I can reuse a name like `cursor` for the pragma as well, added a new name just to be safe. * make sfCallsite recursive, add tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/template/tcallsitelineinfo.nim | 17 | ||||
-rw-r--r-- | tests/template/tcallsitelineinfo2.nim | 20 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/template/tcallsitelineinfo.nim b/tests/template/tcallsitelineinfo.nim new file mode 100644 index 000000000..5fed93363 --- /dev/null +++ b/tests/template/tcallsitelineinfo.nim @@ -0,0 +1,17 @@ +discard """ + nimout: ''' +tcallsitelineinfo.nim(17, 4) Warning: abc [User] +''' + exitcode: 1 + outputsub: ''' +tcallsitelineinfo.nim(17) tcallsitelineinfo +Error: unhandled exception: def [ValueError] +''' +""" + +template foo(): untyped {.callsite.} = + {.warning: "abc".} + raise newException(ValueError, "def") + echo "hello" + +foo() diff --git a/tests/template/tcallsitelineinfo2.nim b/tests/template/tcallsitelineinfo2.nim new file mode 100644 index 000000000..d5f257474 --- /dev/null +++ b/tests/template/tcallsitelineinfo2.nim @@ -0,0 +1,20 @@ +discard """ + nimout: ''' +tcallsitelineinfo2.nim(18, 1) Warning: abc [User] +tcallsitelineinfo2.nim(19, 12) Warning: def [User] +''' + exitcode: 1 + outputsub: ''' +tcallsitelineinfo2.nim(20) tcallsitelineinfo2 +Error: unhandled exception: ghi [ValueError] +''' +""" + +template foo(a: untyped): untyped {.callsite.} = + {.warning: "abc".} + a + echo "hello" + +foo: # with `{.line.}:`, the following do not keep their line information: + {.warning: "def".} + raise newException(ValueError, "ghi") |