diff options
Diffstat (limited to 'tests/macros')
-rw-r--r-- | tests/macros/tmacrostmt.nim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/macros/tmacrostmt.nim b/tests/macros/tmacrostmt.nim index 849a32ea3..a6e1e66dd 100644 --- a/tests/macros/tmacrostmt.nim +++ b/tests/macros/tmacrostmt.nim @@ -24,3 +24,23 @@ macro foo: typed = else: echo "Does not compute! (test OK)" foo() + +#------------------------------------ +# bug #8287 +type MyString = distinct string + +proc `$` (c: MyString): string {.borrow.} + +proc `!!` (c: cstring): int = + c.len + +proc f(name: MyString): int = + !! $ name + +macro repr_and_parse(fn: typed): typed = + let fn_impl = fn.getImpl + fn_impl.name = genSym(nskProc, $fn_impl.name) + echo fn_impl.repr + result = parseStmt(fn_impl.repr) + +repr_and_parse(f) \ No newline at end of file |