summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-06-29 15:34:39 +0200
committerGitHub <noreply@github.com>2021-06-29 15:34:39 +0200
commit97fc95012d2725b625c492b6b72336a89c501076 (patch)
tree669df925450bcad0efcd683efb83451a61052596
parent6387e289631c22b8fa81e8e478c97cc500b90e26 (diff)
downloadNim-97fc95012d2725b625c492b6b72336a89c501076.tar.gz
fixes #16270 (#18388)
-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:
9' href='#n229'>229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336