-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfimprovementparserArea → compiler: The legacy C++ parserArea → compiler: The legacy C++ parser
Description
Previous ID | SR-13098 |
Radar | rdar://problem/64947436 |
Original Reporter | @typesanitizer |
Type | Improvement |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Improvement, Parser |
Assignee | dfsweeney (JIRA) |
Priority | Medium |
md5: 8298353d748ac718f859d5f973f05863
Issue Description:
Consider the following minimal example:
struct T {
var x: Int
}
struct S {
var t: T
t.x = 3
// error: expected 'func' keyword in instance method declaration
// error: expected '(' in argument list of function declaration
// error: consecutive declarations on a line must be separated by ';'
// error: expected declaration
// error: expected '{' in body of function declaration
// error: invalid redeclaration of 't()'
}
A more realistic version can be seen here: https://developer.apple.com/forums/thread/651253
The cascade of errors is quite intimidating. We should:
1. Avoid the cascade of errors, hopefully providing only one or two errors.
2. Provide a more useful diagnostic. For example, we might want to point out that assignments are not permitted at class scope, they must be inside a function. We might also want to say that we expected a property or a function declaration here.
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfimprovementparserArea → compiler: The legacy C++ parserArea → compiler: The legacy C++ parser