summary refs log tree commit diff stats
path: root/tests/magics
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2018-08-22 09:40:31 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-08-22 09:40:31 +0200
commita87341775aa424f252e9e17d58119b0758b58693 (patch)
tree86a2ba9d2936c65d7fc16d58a9c2198bd36955f6 /tests/magics
parent3e7aaa70878d6eda0dfb2737243efae6daa6e26c (diff)
downloadNim-a87341775aa424f252e9e17d58119b0758b58693.tar.gz
Don't consider tyAnd/tyNot/tyOr/tyAnything as generic (#8700)
* Don't consider tyAnd/tyNot/tyOr/tyAnything as generic

`containsGenericType` was too shallow and didn't check all the branches.
The resulting half-processed nodes are often simplified by the constant
folding pass but when that's not possible we get a nasty error during
codegen.

Fixes #8693

* Move the blame onto the semFold pass

Slightly better evaluation of `is` forms.
Diffstat (limited to 'tests/magics')
-rw-r--r--tests/magics/t8693.nim29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/magics/t8693.nim b/tests/magics/t8693.nim
new file mode 100644
index 000000000..554244de4
--- /dev/null
+++ b/tests/magics/t8693.nim
@@ -0,0 +1,29 @@
+discard """
+  output: '''true
+false
+true
+false
+false
+true
+true
+false
+true
+true
+'''
+"""
+
+type Foo = int | float
+
+proc bar(t1, t2: typedesc): bool =
+  echo (t1 is t2)
+  (t2 is t1)
+
+proc bar[T](x: T, t2: typedesc): bool =
+  echo (T is t2)
+  (t2 is T)
+
+echo bar(int, Foo)
+echo bar(4, Foo)
+echo bar(any, int)
+echo bar(int, any)
+echo bar(Foo, Foo)