summary refs log tree commit diff stats
path: root/tests/distinct
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2018-09-27 17:08:01 +0200
committerLemonBoy <thatlemon@gmail.com>2018-09-27 17:08:01 +0200
commite9b5a4e25dcf7929cbda9e67d1775d3ccda82c57 (patch)
tree5ee3c5b9d78994334aa7a40c0debec59b921f71a /tests/distinct
parent72e15ff739cc73fbf6e3090756d3f9cb3d5af2fa (diff)
downloadNim-e9b5a4e25dcf7929cbda9e67d1775d3ccda82c57.tar.gz
Constant folding should not drop distinct types
Fixes #9079
Diffstat (limited to 'tests/distinct')
-rw-r--r--tests/distinct/t9079.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/distinct/t9079.nim b/tests/distinct/t9079.nim
new file mode 100644
index 000000000..a891ef27d
--- /dev/null
+++ b/tests/distinct/t9079.nim
@@ -0,0 +1,19 @@
+discard """
+  output: '''
+25.0
+210.0
+'''
+"""
+
+type
+  Dollars = distinct float
+
+proc `$`(d: Dollars): string {.borrow.}
+proc `*` *(a, b: Dollars): Dollars {.borrow.}
+proc `+` *(a, b: Dollars): Dollars {.borrow.}
+
+var a = Dollars(20)
+a = Dollars(25.0)
+echo a
+a = 10.Dollars * (20.Dollars + 1.Dollars)
+echo a