summary refs log tree commit diff stats
path: root/tests/concepts/t5983.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/concepts/t5983.nim')
-rw-r--r--tests/concepts/t5983.nim22
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
+