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-9399] Source compatibility regression (swift December 1, 2018) #51865

Closed
Agarunov opened this issue Dec 2, 2018 · 4 comments
Closed

[SR-9399] Source compatibility regression (swift December 1, 2018) #51865

Agarunov opened this issue Dec 2, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression source compatibility swift 5.0 type checker Area → compiler: Semantic analysis

Comments

@Agarunov
Copy link

Agarunov commented Dec 2, 2018

Previous ID SR-9399
Radar None
Original Reporter @Agarunov
Type Bug
Status Resolved
Resolution Invalid
Environment

macOS 10.14.1, Xcode 10.1, swift December 1, 2018

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, SourceCompatibility, TypeChecker
Assignee @Agarunov
Priority Medium

md5: 1c30299f8ccef30dd6fa0b93f3bb97ea

Issue Description:

Source compatibility regression in this example code

let optionalArray: [Int]?

if true {
    optionalArray = [1, 2, 3, 4]
} else {
    optionalArray = [5, 6, 7, 8]
    
    // Xcode 10.1
    // swift 4.2.1: no compilation error
    // swift toolchain December 1, 2018: Mutating method 'removeFirst' may not be used on immutable value 'optionalArray'
    optionalArray?.removeFirst()
}
@belkadan
Copy link
Contributor

belkadan commented Dec 3, 2018

Hm. Arguably the new toolchain is correct, but that doesn't mean it's not a source compat break. @rudkx, @xedin?

@rudkx
Copy link
Member

rudkx commented Dec 3, 2018

This diagnostic is emitted by DI.

It looks like expected fallout from #18839.

/cc: @rjmccall

@rjmccall
Copy link
Member

rjmccall commented Dec 3, 2018

Yeah, this example seems like an obvious bug that we don't need to maintain source compatibility with.

@xedin
Copy link
Member

xedin commented Dec 3, 2018

Based on the discussion in comments, it looks like new behavior is correct.

@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 source compatibility swift 5.0 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

6 participants