Skip to content

[SR-7318] Type interference sometimes is wrong on equality check #49866

Open
@swift-ci

Description

@swift-ci
Previous ID SR-7318
Radar rdar://problem/39143381
Original Reporter vhbit (JIRA User)
Type Bug
Environment

Swift 4.1 from Xcode 9.3 (9E145)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.1Regression, TypeChecker
Assignee None
Priority Medium

md5: 30fd51ff3ed5acce33a3e35add5f858d

Issue Description:

It seems that sometimes when checking equality with `.none` the other argument is promoted to Optional which causes unexpected results compared to Swift 4.0

enum Foo {
    case none
    case always
    case smart
}

struct Bar {
    let foo: Foo
}

let x: Foo = .none
x != .none // false as expected

let y: Bar? = Bar(foo: x)
(y?.foo ?? .none) != .none // unexpectedly returns true, worked fine on Swift 4.0
(y?.foo ?? .none) != Foo.none // false as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfregressionswift 4.1type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions