From a87341775aa424f252e9e17d58119b0758b58693 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 22 Aug 2018 09:40:31 +0200 Subject: 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. --- tests/magics/t8693.nim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/magics/t8693.nim (limited to 'tests/magics') 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) -- cgit 1.4.1-2-gfad0