Skip to content

[SR-10816] Changes from SE-0213 break source compatibility in Swift 4 mode #53206

Open
@swift-ci

Description

@swift-ci
Previous ID SR-10816
Radar None
Original Reporter nonsensery (JIRA User)
Type Bug
Environment
  • macOS

  • Xcode 10.1 (Swift 4.2.1) and Xcode 10.2.1 (Swift 5.0.1)

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

md5: 1d1a6270823a72363a7fad6cc34df65c

relates to:

  • SR-10259 ExpressibleByStringLiteral masks an initializer without any warning in Swift 5.

Issue Description:

Steps to reproduce

Note: This issue affects the Swift-4 mode of the Swift 5 compiler.

  1. Execute the following code sample using both the Swift 4 compiler, and the Swift 5 compiler in Swift-4 compatibility mode:
struct TimeOfDay: ExpressibleByStringLiteral {
    init(_ string: String) {
        print("using init(_:)")
    }

    init(stringLiteral: String) {
        print("using init(stringLiteral:)")
    }
}

TimeOfDay.init("00:00")
TimeOfDay("00:00")

Expected result

The code should behave the same in both.

Actual result

In Swift 4, the output is:

using init(_:)
using init(_:)

In Swift-4 compatibility mode, the output is:

using init(_:)
using init(stringLiteral:)

Discussion

I understand that this change in behavior is the result of SE-0213. But, I think that change was only supposed to affect Swift 5 mode.

See this thread on the Swift forums.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfregressionswift 5.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions