diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-09-11 18:35:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-11 18:35:13 +0200 |
commit | 560eef5bbe1820914e94d3252a2d86fbc91ccd00 (patch) | |
tree | c689647ff313b33f054a2146073a8c8e3cf5ed23 /tests/pragmas | |
parent | 33b8a00aa837009a4ad27a7ce5cb52ce06afafa0 (diff) | |
download | Nim-560eef5bbe1820914e94d3252a2d86fbc91ccd00.tar.gz |
fixes #12171 (#12173)
Diffstat (limited to 'tests/pragmas')
-rw-r--r-- | tests/pragmas/t8741.nim | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/pragmas/t8741.nim b/tests/pragmas/t8741.nim index c132c3543..61a449c01 100644 --- a/tests/pragmas/t8741.nim +++ b/tests/pragmas/t8741.nim @@ -1,6 +1,10 @@ discard """ - errormsg: "cannot attach a custom pragma to 'a'" - line: 9 + cmd: "nim check --hint[processing]:off $file" + errormsg: "3 is not two" + nimout: '''t8741.nim(13, 9) Error: cannot attach a custom pragma to 'a' +t8741.nim(29, 15) template/generic instantiation of `onlyTwo` from here +t8741.nim(25, 12) Error: 3 is not two +''' """ for a {.gensym, inject.} in @[1,2,3]: @@ -8,3 +12,18 @@ for a {.gensym, inject.} in @[1,2,3]: for a {.foobar.} in @[1,2,3]: discard + +type Foo[N: static[int]] = distinct int + +proc isTwo(n: int): bool = + n == 2 + +proc onlyTwo[N: static[int]](a: Foo[N]): int = + when isTwo(N): + int(a) + else: + {.error: $(N) & " is not two".} + +when isMainModule: + let foo: Foo[3] = Foo[3](5) + echo onlyTwo(foo) |