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-5233] Another useless diagnostic due to type inference failing #47808

Closed
NachoSoto opened this issue Jun 15, 2017 · 2 comments
Closed

[SR-5233] Another useless diagnostic due to type inference failing #47808

NachoSoto opened this issue Jun 15, 2017 · 2 comments
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-5233
Radar rdar://problem/32801511
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Done
Environment

Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
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 None
Priority Medium

md5: 7ea156d2082cbdcc32155f295f754886

Issue Description:

Another very common example of how Swift makes programming a game of trial and error, because the compiler really doesn't help you with your mistakes (in this case, simply missing argument labels) as much as @lattner would hope.

enum Result<T, E: Error> {
    case success(T)
    case failure(E)
}

enum MyError: Error {
    case error1(a: Int, b: Bool)
}

func f() -> Result<String, MyError> {
    return .failure(.error1(2, true))
}
error: repl.swift:11:13: error: member 'failure' in 'Result<String, MyError>' produces result of type 'Result<T, E>', but context expects 'Result<String, MyError>'
    return .failure(.error1(2, true))

See also SR-5198.

@slavapestov
Copy link
Member

@swift-ci create

@hborla
Copy link
Member

hborla commented Feb 5, 2020

This is resolved in Swift 5.2. The compiler now reports the correct error message about missing argument labels:

error: missing argument labels 'a:b:' in call

  return .failure(.error1(2, true))
                         ^
                          a: b: 

@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

3 participants