diff options
author | cooldome <cdome@bk.ru> | 2018-07-12 11:03:08 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-07-12 11:03:08 +0200 |
commit | 231a83a6b108dc676b53ba5f906d51ff14aa5b51 (patch) | |
tree | baeb423ff0d363edb2ad8e70c43b3ffe2293d9a4 /tests/macros | |
parent | ac3c4a94add9e21e9f0731f39be88cdba2bec010 (diff) | |
download | Nim-231a83a6b108dc676b53ba5f906d51ff14aa5b51.tar.gz |
Fixes #8287 (#8288)
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 |