summary refs log tree commit diff stats
path: root/tests/macros/t20435.nim
blob: 824282198cfe0b1e593d0472b8d158e93da1d5c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#[
  A better test requires matching, so the use of @ working can be showcased
  For example:

  proc regularCase[T]() = 
    case [(1, 3), (3, 4)]:
    of [(1, @a), (_, @b)]:
      echo a, b
    else: discard
]#

{.experimental: "caseStmtMacros".}

import macros

type Foo = object

macro `case`(obj: Foo) = quote do: discard

proc notGeneric() =
  case Foo()
  of a b c d: discard

proc generic[T]() =
  case Foo()
  of a b c d: discard

notGeneric()
generic[int]()