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-10703] Parser should specially diagnose misplaced “throws” in function types #53100

Closed
beccadax opened this issue May 17, 2019 · 3 comments
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser

Comments

@beccadax
Copy link
Contributor

Previous ID SR-10703
Radar None
Original Reporter @beccadax
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, Parser, StarterBug
Assignee tt (JIRA)
Priority Medium

md5: 34c4b72d4d7ba51900b9fe26030ef810

Issue Description:

In function declarations, the parser looks for a throws after the -> token instead of before it; if it finds one, it diagnoses a special error with a fix-it swapping the two tokens. But if you make the same mistake in a function type, Swift shows a series of mildly confusing error messages like “expected type for function result”. Function types should provide a similar experience to function declarations.

The code that does this for function declarations is in a method called parseFunctionSignature(). The test case for this feature would look something like this (although the fix-it might actually be done slightly differently):

let fn: () -> throws Void  // expected-error{{‘throws’ may only occur before ‘->’}} {{12-12=throws }} {{15-22=}}
@swift-ci
Copy link
Collaborator

swift-ci commented Jun 7, 2019

Comment by Tapan Thaker (JIRA)

Taking this up for Try Swift San Jose 2019

@beccadax
Copy link
Contributor Author

beccadax commented Jun 7, 2019

tt (JIRA User) Great! If you need help, I’ll be around after lunch.

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 8, 2019

Comment by Tapan Thaker (JIRA)

Resolved in PR #25306

@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
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

2 participants