mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 14:23:45 +00:00
* test not restricting custom pragma applied symbols fixes #21652 * fix other test * different patch * fix tests * actually test #18212 and other routines
30 lines
622 B
Nim
30 lines
622 B
Nim
discard """
|
|
cmd: "nim check --hint:processing:off $file"
|
|
errormsg: "3 is not two"
|
|
nimout: '''t8741.nim(13, 9) Error: invalid pragma: foobar
|
|
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]:
|
|
discard
|
|
|
|
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)
|