summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/ast.nim4
-rw-r--r--compiler/semdata.nim3
-rw-r--r--compiler/semexprs.nim2
-rw-r--r--compiler/semtypes.nim4
-rw-r--r--compiler/semtypinst.nim4
-rw-r--r--compiler/sigmatch.nim4
-rw-r--r--tests/cpp/tget_subsystem.nim (renamed from tests/cpp/get_subsystem.nim)3
-rw-r--r--tests/cpp/tvector_iterator.nim (renamed from tests/cpp/vector_iterator.nim)0
-rw-r--r--tests/macros/typesapi2.nim4
-rw-r--r--tests/types/tisopr.nim41
10 files changed, 58 insertions, 11 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 4e22af287..1b14a8f79 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1171,7 +1171,9 @@ proc newType*(kind: TTypeKind, owner: PSym): PType =
   result.lockLevel = UnspecifiedLockLevel
   when debugIds:
     registerId(result)
-  #if result.id < 2000:
+  #if result.id == 92231:
+  #  echo "KNID ", kind
+  #  writeStackTrace()
   #  messageOut(typeKindToStr[kind] & ' has id: ' & toString(result.id))
 
 proc mergeLoc(a: var TLoc, b: TLoc) =
diff --git a/compiler/semdata.nim b/compiler/semdata.nim
index cf7a52ff5..1c2720006 100644
--- a/compiler/semdata.nim
+++ b/compiler/semdata.nim
@@ -247,6 +247,7 @@ proc makeAndType*(c: PContext, t1, t2: PType): PType =
   propagateToOwner(result, t1)
   propagateToOwner(result, t2)
   result.flags.incl((t1.flags + t2.flags) * {tfHasStatic})
+  result.flags.incl tfHasMeta
 
 proc makeOrType*(c: PContext, t1, t2: PType): PType =
   result = newTypeS(tyOr, c)
@@ -254,12 +255,14 @@ proc makeOrType*(c: PContext, t1, t2: PType): PType =
   propagateToOwner(result, t1)
   propagateToOwner(result, t2)
   result.flags.incl((t1.flags + t2.flags) * {tfHasStatic})
+  result.flags.incl tfHasMeta
 
 proc makeNotType*(c: PContext, t1: PType): PType =
   result = newTypeS(tyNot, c)
   result.sons = @[t1]
   propagateToOwner(result, t1)
   result.flags.incl(t1.flags * {tfHasStatic})
+  result.flags.incl tfHasMeta
 
 proc nMinusOne*(n: PNode): PNode =
   result = newNode(nkCall, n.info, @[
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index c5bfbfa92..eb8d0c561 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -389,7 +389,7 @@ proc isOpImpl(c: PContext, n: PNode): PNode =
     maybeLiftType(t2, c, n.info)
     var m: TCandidate
     initCandidate(c, m, t2)
-    let match = typeRel(m, t2, t1) != isNone
+    let match = typeRel(m, t2, t1) >= isSubtype # isNone
     result = newIntNode(nkIntLit, ord(match))
 
   result.typ = n.typ
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 4a45da2f9..9e36341bb 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -834,7 +834,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
       cp.kind = tyUserTypeClassInst
       return addImplicitGeneric(cp)
 
-    for i in 1 .. (paramType.sons.len - 2):
+    for i in 1 .. paramType.len-2:
       var lifted = liftingWalk(paramType.sons[i])
       if lifted != nil:
         paramType.sons[i] = lifted
@@ -847,7 +847,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
       result.shouldHaveMeta
 
   of tyGenericInvocation:
-    for i in 1 .. <paramType.sonsLen:
+    for i in 1 .. <paramType.len:
       let lifted = liftingWalk(paramType.sons[i])
       if lifted != nil: paramType.sons[i] = lifted
     when false:
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index 914b92fc8..c5caf8b92 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -233,7 +233,9 @@ proc instCopyType*(cl: var TReplTypeVars, t: PType): PType =
   # XXX: relying on allowMetaTypes is a kludge
   result = copyType(t, t.owner, cl.allowMetaTypes)
   result.flags.incl tfFromGeneric
-  result.flags.excl tfInstClearedFlags
+  if not (t.kind in tyMetaTypes or
+         (t.kind == tyStatic and t.n == nil)):
+    result.flags.excl tfInstClearedFlags
 
 proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
   # tyGenericInvocation[A, tyGenericInvocation[A, B]]
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index faa84de15..5c8a3bc58 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1108,8 +1108,10 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
       localError(f.n.info, errTypeExpected)
       result = isNone
 
+  of tyNone:
+    if a.kind == tyNone: result = isEqual
   else:
-    internalAssert false
+    internalError " unknown type kind " & $f.kind
 
 proc cmpTypes*(c: PContext, f, a: PType): TTypeRelation =
   var m: TCandidate
diff --git a/tests/cpp/get_subsystem.nim b/tests/cpp/tget_subsystem.nim
index 38593b03a..461914739 100644
--- a/tests/cpp/get_subsystem.nim
+++ b/tests/cpp/tget_subsystem.nim
@@ -16,7 +16,8 @@ struct SystemManager {
 """.}
 
 type Input {.importcpp: "System::Input".} = object
-proc getSubsystem*[T](): ptr T {.importcpp: "SystemManager::getSubsystem<'*0>()".}
+proc getSubsystem*[T](): ptr T {.
+  importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.}
 
 let input: ptr Input = getSubsystem[Input]()
 
diff --git a/tests/cpp/vector_iterator.nim b/tests/cpp/tvector_iterator.nim
index cb5ab33af..cb5ab33af 100644
--- a/tests/cpp/vector_iterator.nim
+++ b/tests/cpp/tvector_iterator.nim
diff --git a/tests/macros/typesapi2.nim b/tests/macros/typesapi2.nim
index 016295ba4..2e59d2154 100644
--- a/tests/macros/typesapi2.nim
+++ b/tests/macros/typesapi2.nim
@@ -1,4 +1,4 @@
-# tests to see if a symbol returned from macros.getType() can 
+# tests to see if a symbol returned from macros.getType() can
 # be used as a type
 import macros
 
@@ -20,7 +20,7 @@ static: assert iii is TestFN
 
 proc foo11 : testTypesym(void) =
     echo "HI!"
-static: assert foo11 is proc():void
+static: assert foo11 is (proc():void {.nimcall.})
 
 var sss: testTypesym(seq[int])
 static: assert sss is seq[int]
diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim
index 8b7fe4e46..b9acfa5fb 100644
--- a/tests/types/tisopr.nim
+++ b/tests/types/tisopr.nim
@@ -1,5 +1,11 @@
 discard """
-  output: '''true true false yes'''
+  output: '''true true false yes
+false
+false
+false
+true
+true
+no'''
 """
 
 proc IsVoid[T](): string =
@@ -28,7 +34,7 @@ no  s.items is iterator: float
 yes s.items is iterator: TNumber
 no  s.items is iterator: object
 
-type 
+type
   Iter[T] = iterator: T
 
 yes s.items is Iter[TNumber]
@@ -51,3 +57,34 @@ yes Foo[4, int] is Bar[int]
 no Foo[4, int] is Baz[4]
 yes Foo[4, float] is Baz[4]
 
+
+# bug #2505
+
+echo(8'i8 is int32)
+
+# bug #1853
+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.
+echo seq is SeqOrSet
+
+# This prints "false", as expected.
+echo seq is SeqOrSetOfInt
+
+# This prints "true", as expected.
+echo SeqOfInt is SeqOrSet
+
+# This causes an internal error (filename: compiler/semtypes.nim, line: 685).
+echo SeqOfInt is SeqOrSetOfInt
+
+# bug #2522
+proc test[T](x: T) =
+  when T is typedesc:
+    echo "yes"
+  else:
+    echo "no"
+
+test(7)