diff options
author | Zahary Karadjov <zahary@gmail.com> | 2017-06-19 23:01:41 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-06-20 11:29:42 +0200 |
commit | 07d50cedf012ff8ca39c61c0ba5c43e5d588e630 (patch) | |
tree | b9864682618a22350123b3a3ae3f61c52382d18d /tests/concepts | |
parent | 21ce7b2af4163b2513f3c6cbf2f52929d684bcb3 (diff) | |
download | Nim-07d50cedf012ff8ca39c61c0ba5c43e5d588e630.tar.gz |
Fix #5983
Diffstat (limited to 'tests/concepts')
-rw-r--r-- | tests/concepts/t5983.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/concepts/t5983.nim b/tests/concepts/t5983.nim new file mode 100644 index 000000000..e69647448 --- /dev/null +++ b/tests/concepts/t5983.nim @@ -0,0 +1,22 @@ +discard """ + output: "20.0 USD" +""" + +import typetraits + +const currencies = ["USD", "EUR"] # in real code 120 currencies + +type USD* = distinct float # in real code 120 types generates using macro +type EUR* = distinct float + +type CurrencyAmount = concept c + type t = c.type + const name = c.type.name + name in currencies + +proc `$`(x: CurrencyAmount): string = + $float(x) & " " & x.name + +let amount = 20.USD +echo amount + |