summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semexprs.nim6
-rw-r--r--compiler/semfold.nim43
-rw-r--r--tests/magics/t8693.nim6
-rw-r--r--tests/types/tisopr.nim6
4 files changed, 14 insertions, 47 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index a71796de2..660d538ed 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -403,10 +403,8 @@ proc semIs(c: PContext, n: PNode, flags: TExprFlags): PNode =
       n[1] = makeTypeSymNode(c, lhsType, n[1].info)
       lhsType = n[1].typ
   else:
-    if lhsType.base.kind == tyNone:
-      # this is a typedesc variable, leave for evals
-      return
-    if lhsType.base.containsGenericType:
+    internalAssert c.config, lhsType.base.kind != tyNone
+    if c.inGenericContext > 0 and lhsType.base.containsGenericType:
       # BUGFIX: don't evaluate this too early: ``T is void``
       return
 
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index 92305fd11..53c9af07a 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -174,43 +174,6 @@ proc makeRangeF(typ: PType, first, last: BiggestFloat; g: ModuleGraph): PType =
   result.n = n
   addSonSkipIntLit(result, skipTypes(typ, {tyRange}))
 
-proc evalIs(n: PNode, lhs: PSym, g: ModuleGraph): PNode =
-  # XXX: This should use the standard isOpImpl
-  internalAssert g.config,
-    n.sonsLen == 3 and
-    lhs.typ != nil and
-    n[2].kind in {nkStrLit..nkTripleStrLit, nkType}
-
-  var
-    res = false
-    t1 = lhs.typ
-    t2 = n[2].typ
-
-  if t1.kind == tyTypeDesc and t2.kind != tyTypeDesc:
-    t1 = t1.base
-
-  if n[2].kind in {nkStrLit..nkTripleStrLit}:
-    case n[2].strVal.normalize
-    of "closure":
-      let t = skipTypes(t1, abstractRange)
-      res = t.kind == tyProc and
-            t.callConv == ccClosure and
-            tfIterator notin t.flags
-    of "iterator":
-      let t = skipTypes(t1, abstractRange)
-      res = t.kind == tyProc and
-            t.callConv == ccClosure and
-            tfIterator in t.flags
-    else:
-      res = false
-  else:
-    # XXX semexprs.isOpImpl is slightly different and requires a context. yay.
-    let t2 = n[2].typ
-    res = sameType(t1, t2)
-
-  result = newIntNode(nkIntLit, ord(res))
-  result.typ = n.typ
-
 proc fitLiteral(c: ConfigRef, n: PNode): PNode =
   # Trim the literal value in order to make it fit in the destination type
   if n == nil:
@@ -673,9 +636,9 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode =
       of mConStrStr:
         result = foldConStrStr(m, n, g)
       of mIs:
-        let lhs = getConstExpr(m, n[1], g)
-        if lhs != nil and lhs.kind == nkSym:
-          result = evalIs(n, lhs.sym, g)
+        # The only kind of mIs node that comes here is one depending on some
+        # generic parameter and that's (hopefully) handled at instantiation time
+        discard
       else:
         result = magicCall(m, n, g)
     except OverflowError:
diff --git a/tests/magics/t8693.nim b/tests/magics/t8693.nim
index 554244de4..71468116b 100644
--- a/tests/magics/t8693.nim
+++ b/tests/magics/t8693.nim
@@ -9,6 +9,10 @@ true
 false
 true
 true
+false
+true
+true
+false
 '''
 """
 
@@ -27,3 +31,5 @@ echo bar(4, Foo)
 echo bar(any, int)
 echo bar(int, any)
 echo bar(Foo, Foo)
+echo bar(any, Foo)
+echo bar(Foo, any)
diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim
index f05f443de..636377301 100644
--- a/tests/types/tisopr.nim
+++ b/tests/types/tisopr.nim
@@ -1,7 +1,7 @@
 discard """
   output: '''true true false yes
 false
-false
+true
 false
 true
 true
@@ -68,8 +68,8 @@ type SeqOrSet[E] = seq[E] or set[E]
 type SeqOfInt = seq[int]
 type SeqOrSetOfInt = SeqOrSet[int]
 
-# This prints "false", which seems less correct that (1) printing "true" or (2)
-# raising a compiler error.
+# This prints "true", as expected. Previously "false" was returned and that
+# seemed less correct that (1) printing "true" or (2) raising a compiler error.
 echo seq is SeqOrSet
 
 # This prints "false", as expected.