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-9785] The swiftc compiler in Xcode 10.2 Beta (10P82s) in Swift 4.2 mode reports an ambiguous use error for code that previously worked fine #52211

Closed
swift-ci opened this issue Jan 28, 2019 · 3 comments
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

@swift-ci
Copy link
Collaborator

Previous ID SR-9785
Radar rdar://problem/47788145
Original Reporter stephan (JIRA User)
Type Bug
Status Resolved
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, SourceCompatibility, TypeChecker
Assignee None
Priority Medium

md5: 7f201a88976e91c2c463d81b0fd65775

Issue Description:

Steps to reproduce with Xcode 10.2 Beta (10P82s, swiftlang-1001.0.45.7):

/Demo/Features/UDHRViewerVC.swift:379:18: error: ambiguous use of 'init'
    background = STUBackgroundAttribute { b in
                 ^
STULabel.STUBackgroundAttribute:6:24: note: found this candidate
    public convenience init(__block block: (STUBackgroundAttributeBuilder) -> Void)
                       ^
STULabelSwift.STUBackgroundAttribute:2:35: note: found this candidate
    @inlinable public convenience init(_ configure: (STUBackgroundAttributeBuilder) -> Void)

The Swift compiler in Xcode 10.1 (10B61) doesn't report this error.

Note: The STULabelSwift extensions with initializers accepting a closure are a workaround for SR-6894.

@belkadan
Copy link
Contributor

Reproduced. I'm honestly not sure how this would have been working before—it seems like this really ought to be ambiguous?

@DougGregor, @xedin, have we seen something like this? It sounds a little familiar.

@xedin
Copy link
Member

xedin commented Jan 29, 2019

This is minimized example:

struct A {}
struct B {
  init(a: (A) -> Void) {}
  init(_ b: (A) -> Void) {}
}

_ = B { a in }

It used to work before only if the second overload doesn't have a label. I think this is ought to be ambiguous though because trailing closures do not require labels, @DougGregor WDYT?

stephan (JIRA User) If you form a proper call e.g. `_ B({ a in })` that would resolve ambiguity in favor of label-less overload, or you can do `_ = B(a: { a in })` to use the first one.

@DougGregor
Copy link
Member

I agree that this should always have been ambiguous. Trailing closures mean that the label on the last parameter is uninteresting from a ranking perspective when it has function type.

@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

5 participants