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-14270] Add test case for diagnostic note 'because_rethrows_default_argument_throws' #56630
Comments
@swift-ci create |
Here is an example test case: func f(_ k: () throws -> () = { }) rethrows {
try k()
}
let x = f() I think this should be added alongside related tests on diagnostics for rethrows. |
It seems like this diagnostic is a stop-gap until we fix the problem. |
Comment by Kenneth Chew (JIRA) For clarification, there should not be any expected error and diagnostic here, correct? The error that shows up ("Call is to rethrows function, but a defaulted argument function can throw") should not appear? This seems to be what I gather from looking through SR-1534. Meanwhile something like func x(_ f: () throws -> () = { throw SomeError.Badness }) rethrows {
try f()
}
x() should have the error and diagnostic? |
In an ideal world where SR-1534 is fixed, yes. However, I think that fixing SR-1534 is probably complicated and beyond the scope of a StarterBug. The task in this bug report is to add the test case along with the diagnostic to "pin down" the compiler's behavior today; in case someone else tries to understand when that diagnostic is emitted, they can take a look at the test case. If/When someone fixes SR-1534 in the future, they can change this test case from "error" to "works okay". So you can add two test cases like so: // Should continue to emit an error after SR-1534 is fixed.
func f1(_ k: () throws -> () = { throw SomeError.Badness }) rethrows {
// expected-error@-1{{ blah }}
try k()
}
f1()
// Once SR-1534 is fixed, this code should compile instead of emitting an error.
func f2(_ k: () throws -> () = { }) rethrows {
// expected-error@-1{{ blah }}
try k()
}
f2() Does that help? |
Comment by Kenneth Chew (JIRA) Yes, that's very helpful, thank you! I made a PR at #36455 - could you look at it when you get a chance, please? |
Comment by Kenneth Chew (JIRA) Added in #36455 |
Additional Detail from JIRA
md5: 083b76192dd95f0bbee3ed778bd3fc85
relates to:
Issue Description:
This diagnostic does have some code, but from what I can tell, it has no associated test cases. We should at least have 1 test case so it is clearer when exactly this diagnostic is emitted.
The text was updated successfully, but these errors were encountered: