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-13432] No warning diagnostic generated for closure with Never argument #55873

Closed
swift-ci opened this issue Aug 23, 2020 · 2 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 SILGen Area → compiler: The SIL generation stage

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13432
Radar None
Original Reporter kdubb0 (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, SILGen
Assignee @theblixguy
Priority Medium

md5: 5b5c27c42f2ac243167ed3f88bea66e5

Issue Description:

When providing a single expression closure with an implicit return and takes a `Never` parameter, no warning is generated.

Examples:

func map<T>(_ block: (Never) -> T) {}
// No warning 
map { _ in 5 }
// No warning 
map { _ in
  5
}
 
// Warning
map { _ in
  return 5
}

This is very problematic when chaining results in Combine because the author is not notified that the publisher will not react accordingly.

For example, the following combine code issues no warnings and never prints a value!

somethingThatGeneratesANeverOutputPublisher()
  .map { _ in 5 }
  .sink { _ in
  } receiveValue: { value in
    print(value)
  }
@theblixguy
Copy link
Collaborator

Here's a fix: #33604

@theblixguy
Copy link
Collaborator

Fixed on master. Please verify using the next available trunk snapshot from swift.org![]( 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 SILGen Area → compiler: The SIL generation stage
Projects
None yet
Development

No branches or pull requests

2 participants