Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10914] Swift 5.1 compiler fails to compile code containing Data created with an array literal. #53305

Closed
swift-ci opened this issue Jun 11, 2019 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.1 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10914
Radar https://feedbackassistant.apple.com/feedback/6145103
Original Reporter serieuxchat (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Apple Swift version 5.1 (swiftlang-1100.0.38.29 clang-1100.0.20.14)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.1Regression, TypeChecker
Assignee serieuxchat (JIRA)
Priority Medium

md5: cdc4e73c83b08acdad6a01763761c9da

Issue Description:

Xcode 11.0 beta (11M336w), Swift 5.1 compiler fails to compile code containing Data created with an array literal.

  1. Open attached sample project.

  2. Compile for the Simulator (iPhone Xr).

  3. Observe the error: "DataWrapper.swift:28:17: error: expression type 'DataWrapper' is ambiguous without more context DataWrapper.create(from: Data("

  4. Comment out the definition of the variable "thisDoesNotCompile"

  5. Compile again.

  6. Now it compiles. Please see the definition of the variable "thisCompiles" which uses an array literal of smaller size.

I am running Mac OS Mojave 10.14.5 and have both Xcode 10.2.1 (10E1001) and Xcode 11.0 beta (11M336w) installed.

@stephentyrone
Copy link
Member

Extracting some notes for folks to get a quick picture without opening the project: the compilation failure happens when calling the following function:

    public static func create(from data1: Data, data2: Data) -> DataWrapper {
        let result = DataWrapper()
        result.inner = data1 + data2
        return result
    }

where the two arguments both have the form Data([2000ish literals]). Splitting the code up to assign each Data to a variable and then calling create(from: a, data2: b) resolves the compilation failure.

@stephentyrone
Copy link
Member

Thanks for a nice bug writeup, serieuxchat (JIRA User)!

@swift-ci
Copy link
Collaborator Author

Comment by Michael Henderson (JIRA)

nice write up. It def makes understanding and reproducing the issue a lot less brutal. 🙂

@xedin
Copy link
Member

xedin commented Jun 21, 2019

I have opened a PR to fix this problem - #25666

@xedin
Copy link
Member

xedin commented Jun 24, 2019

Resolved by #25666 serieuxchat (JIRA User) Please use next available nightly snapshot of master to verify. I also got 5.1 PR opened.

@swift-ci
Copy link
Collaborator Author

Comment by Sergey A. Novitsky (JIRA)

Works with Xcode 11 beta 5. Thanks!

1 similar comment
@swift-ci
Copy link
Collaborator Author

Comment by Sergey A. Novitsky (JIRA)

Works with Xcode 11 beta 5. Thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.1 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants