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
Need better recovery for statements at the top level #10554
Comments
Set owner to @bwilkerson. |
Although 'enum' is a reserved word, the bigger issue here is poor error recovery when encountering a statement at the top level. Changed the title to: "Need better recovery for statements at the top level". |
Added Analyzer-Recovery label. |
Removed Type-Defect label. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
This one is wild. It still produces a 11 errors/warnings! DartPad repro (warnings are truncated to first 5).
If you wrap the last line (the forEach statement) in a function, like If you instead convert each case of the So I think the 2 bugs in this issue are:
e.g. each of the three examples below produces similar crazy errors: void main() {
//for (enum in [1,2,3]) {
// print(enum);
//}
//for (in in [1,2,3]) {
// print(in);
//}
for (continue in [1,2,3]) {
print(continue);
}
} |
3-year update:
The following code still produces too many errors: void main() {
// 4 errors.
for (enum in [1,2,3]) {
print(enum);
}
// 4 errors.
for (in in [1,2,3]) {
print(in);
}
// 5 errors.
for (continue in [1,2,3]) {
print(continue);
}
} |
This issue was originally filed by @orian
Reproduce:
class SomeClass {
int id;
SomeClass(this.id);
}
var VAL1 = new SomeClass(1);
var VAL2 = new SomeClass(2);
var valById = {};
var allValues = [VAL1, VAL2];
allValues.forEach((enum) => result[enum.id] = enum);
Error shown by Eclipse:
Multiple markers at this line
- Expected to find ';'
- Unexpected token
'enum'
- Undefined name ''
- Unexpected token ')'
- Undefined name ''
- Undefined name ''
- Undefined name ''
- Undefined name ''
- Expected a statement
- Expected to find ';'
- Expected to find ';'
- Unexpected token
'enum'
- Unexpected token ']'
- Expected a statement
- Expected to find ';'
- Expected to find ';'
- Expected a statement
- Unexpected token
'enum'
- Expected to find ';'
- Unexpected token ')'
- Expected to find ';'
- Unexpected token '=>'
- Expected to find ']'
- Expected to find ')'
- Undefined name ''
- Undefined name ''
- Undefined name ''
- Undefined name ''
What is the expected output?
"Wrong use of keyword", "Keyword used as a variable name" etc.
What version of the product are you using? On what operating system?
0.5.5_r22416, Linux,
Please provide any additional information below.
Was there an official announcment of "enum" becoming reserved keyword?
The text was updated successfully, but these errors were encountered: