mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-10 15:04:59 +00:00
fixes #20435 --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Jake Leahy <jake@leahy.dev> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
31 lines
469 B
Nim
31 lines
469 B
Nim
|
|
#[
|
|
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]()
|