Advertisement
Guest User

Untitled

a guest
May 5th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.50 KB | None | 0 0
  1. import macros
  2. macro examine(x: untyped): untyped =
  3.   debugEcho(x.treeRepr)
  4.   return x
  5.  
  6. examine:  
  7.   type
  8.     foobar = enum
  9.       somekind
  10.     thingy = object
  11.       case kind: foobar
  12.       of somekind:
  13.         value: int
  14.  
  15. macro fail(x: untyped): untyped =
  16.   result = quote:
  17.     type
  18.       foobar = enum
  19.         somekind
  20.       thingy = object
  21.         case kind: foobar
  22.         of somekind:
  23.           value: int
  24.   debugEcho(result.treeRepr)
  25.  
  26. const broken = true
  27.  
  28. when broken:
  29.   fail(foo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement