summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/ast.nim3
-rw-r--r--compiler/semexprs.nim1
-rw-r--r--compiler/sigmatch.nim9
3 files changed, 10 insertions, 3 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 56043692f..2a2a84e76 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -499,7 +499,7 @@ type
     nfFirstWrite# this node is a first write
 
   TNodeFlags* = set[TNodeFlag]
-  TTypeFlag* = enum   # keep below 32 for efficiency reasons (now: ~40)
+  TTypeFlag* = enum   # keep below 32 for efficiency reasons (now: 43)
     tfVarargs,        # procedure has C styled varargs
                       # tyArray type represeting a varargs list
     tfNoSideEffect,   # procedure type does not allow side effects
@@ -566,6 +566,7 @@ type
       # (for importc types); type is fully specified, allowing to compute
       # sizeof, alignof, offsetof at CT
     tfExplicitCallConv
+    tfIsConstructor
 
   TTypeFlags* = set[TTypeFlag]
 
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index c885f4963..acf408db0 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -2412,6 +2412,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
 proc semSetConstr(c: PContext, n: PNode): PNode =
   result = newNodeI(nkCurly, n.info)
   result.typ = newTypeS(tySet, c)
+  result.typ.flags.incl tfIsConstructor
   if n.len == 0:
     rawAddSon(result.typ, newTypeS(tyEmpty, c))
   else:
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index b2003c0a8..071685057 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1341,8 +1341,13 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
         result = isSubtype
       else:
         result = typeRel(c, f[0], a[0], flags)
-        if result <= isConvertible:
-          result = isNone     # BUGFIX!
+        if result < isGeneric:
+          if result <= isConvertible:
+            result = isNone
+          elif tfIsConstructor notin a.flags:
+            # set constructors are a bit special...
+            result = isNone
+
   of tyPtr, tyRef:
     skipOwned(a)
     if a.kind == f.kind: