t20435.nim 469 B

12345678910111213141516171819202122232425262728293031
  1. #[
  2. A better test requires matching, so the use of @ working can be showcased
  3. For example:
  4. proc regularCase[T]() =
  5. case [(1, 3), (3, 4)]:
  6. of [(1, @a), (_, @b)]:
  7. echo a, b
  8. else: discard
  9. ]#
  10. {.experimental: "caseStmtMacros".}
  11. import macros
  12. type Foo = object
  13. macro `case`(obj: Foo) = quote do: discard
  14. proc notGeneric() =
  15. case Foo()
  16. of a b c d: discard
  17. proc generic[T]() =
  18. case Foo()
  19. of a b c d: discard
  20. notGeneric()
  21. generic[int]()