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.
This commit is contained in:
parent
3e7aaa7087
commit
a87341775a
3 changed files with 63 additions and 17 deletions
29
tests/magics/t8693.nim
Normal file
29
tests/magics/t8693.nim
Normal file
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue