Skip to content

Conversation

@jrose-apple
Copy link
Contributor

...allowing a plain return to work in a switch in a Void-returning function.

SR-9920

@jrose-apple jrose-apple requested a review from rintaro February 28, 2019 04:30
@jrose-apple
Copy link
Contributor Author

@rintaro Can you think of any other test cases I should add, or related issues I should fix while I'm here?

@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@rintaro
Copy link
Member

rintaro commented Feb 28, 2019

👍
This patch should improve recovery for:

enum E {
  case foo, bar
}
func foo(e: E) {
  switch e {
  case .foo:
    _ = [1
  @unknown default:
    ()
  }
}
$ ../build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift test.swift
test.swift:8:11: error: expected ',' separator
    _ = [1
          ^
          ,
test.swift:9:3: error: expected expression in container literal
  @unknown default:
  ^
test.swift:6:3: error: switch must be exhaustive
  switch e {
  ^
test.swift:6:3: note: add missing case: '.bar'
  switch e {
  ^

...allowing a plain 'return' to work in a switch in a Void-returning
function.

https://bugs.swift.org/browse/SR-9920
@jrose-apple jrose-apple force-pushed the return-to-the-unknown branch from 146eef1 to 048f5a4 Compare March 1, 2019 03:42
@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test

@jrose-apple jrose-apple merged commit 003850f into swiftlang:master Mar 1, 2019
@jrose-apple jrose-apple deleted the return-to-the-unknown branch March 1, 2019 16:31
akyrtzi added a commit to akyrtzi/swift that referenced this pull request Mar 17, 2019
…ment level

This infinite loop case was introduced after changes of swiftlang#22974
It was found by the stress tester.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants