diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 62302146f16e8..5b0b7939322dd 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -974,9 +974,7 @@ proc cow(p: BProc; n: PNode) {.inline.} = if n.kind == nkHiddenAddr: cowBracket(p, n[0]) template ignoreConv(e: PNode): bool = - let destType = e.typ.skipTypes({tyVar, tyLent, tyGenericInst, tyAlias, tySink}) - let srcType = e[1].typ.skipTypes({tyVar, tyLent, tyGenericInst, tyAlias, tySink}) - sameBackendTypePickyAliases(destType, srcType) + sameBackendTypePickyAliases(e.typ, e[1].typ) proc genAddr(p: BProc, e: PNode, d: var TLoc) = # careful 'addr(myptrToArray)' needs to get the ampersand: diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index aa0489cd225f1..9f61fe6f26b88 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -578,7 +578,14 @@ proc isOpImpl(c: PContext, n: PNode, flags: TExprFlags): PNode = if efExplain in flags: m.diagnostics = @[] m.diagnosticsEnabled = true - res = typeRel(m, t2, t1) >= isSubtype # isNone + let rel = typeRel(m, t2, t1) + res = rel >= isSubtype # isNone + if res and rel == isEqual and + not compareTypes(t1, t2, + flags = {ExactTypeDescValues, + PickyCAliases, + PickyBackendAliases}): + res = false # `res = sameType(t1, t2)` would be wrong, e.g. for `int is (int|float)` result = newIntNode(nkIntLit, ord(res)) diff --git a/compiler/seminst.nim b/compiler/seminst.nim index a34467636a3b0..7d0585d4443d1 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -81,7 +81,8 @@ proc sameInstantiation(a, b: TInstantiation): bool = if not compareTypes(a.concreteTypes[i], b.concreteTypes[i], flags = {ExactTypeDescValues, ExactGcSafety, - PickyCAliases}): return + PickyCAliases, + PickyBackendAliases}): return result = true else: result = false diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 5f846c80ac592..326fbd63f700c 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -52,7 +52,8 @@ proc searchInstTypes*(g: ModuleGraph; key: PType): PType = for j in FirstGenericParamAt..