[SR-10703] Parser should specially diagnose misplaced “throws” in function types #53100
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
Additional Detail from JIRA
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):The text was updated successfully, but these errors were encountered: