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-5261] Another "Expression is ambiguous without more context" example #47836

Closed
NachoSoto opened this issue Jun 19, 2017 · 8 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-5261
Radar rdar://problem/33914444
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee @NachoSoto
Priority Medium

md5: a67420049f6043928f5aac4ad037282a

Issue Description:

struct A {
    enum R<T, E: Error> {
        case t(T)
        case e(E)
    }

    struct S {
        enum E: Error {
            case e1
        }
        
        let x: String
        let e: R<Int, E>
    }
}

extension A.S {
    func f() -> A.S {
        switch self.e {
            case let .t(x) where x == 0:
                return A.S(x: self.x, e: .e1) // Note that this is missing .e(.e1)

            default:
                return self
        }
    }
}
error: repl.swift:21:26: error: expression type 'A.S' is ambiguous without more context
                return A.S(x: self.x, e: .e1)
                       ~~^~~~~~~~~~~~~~~~~~~~

Note that the diagnostic is correct if types aren't namespaces inside A.

@slavapestov
Copy link
Member

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Aug 16, 2017

I see that with Xcode 9 beta 2, but with beta 4 and beyond I get:

error: type 'A.R<Int, A.S.E>' has no member 'e1'
      return A.S(x: self.x, e: .e1) // Note that this is missing .e(.e1)
                               ~^
note: did you mean 'e'?
  case e(E)

@NachoSoto
Copy link
Contributor Author

Yeah, I can confirm that. Are there regression tests for this though? Given that this only reproduced when the function was namespaced leads me to believe that maybe it only works by coincidence 😛

@rudkx
Copy link
Member

rudkx commented Aug 16, 2017

@xedin is the best person to answer that.

@xedin
Copy link
Member

xedin commented Aug 16, 2017

I'm pretty sure we have something similar already but the safest way is to add this example, which I'm going to do 🙂

@NachoSoto
Copy link
Contributor Author

<3

@xedin
Copy link
Member

xedin commented Aug 16, 2017

Test case has been added by #11486

@NachoSoto
Copy link
Contributor Author

Thank you! 🙂

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants