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

Ridiculous number of compiler errors for a missing open { on top-level #25652

Open
DavidSouther opened this issue Feb 2, 2016 · 5 comments
Open
Labels
analyzer-recovery area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DavidSouther
Copy link

Compare:
https://dartpad.dartlang.org/8f24e1eb9c237c01bcb3

http://www.typescriptlang.org/Playground#src=%0Afunction%20main()%0A%20%20var%20lines%20%3D%20getLines()%3B%0A%0A%20%20%2F%2F%20If%20result%20is%20non-null%2C%20print%20it.%0A%20%20if(lines%20!%3D%3D%20null)%20%7B%0A%09lines.forEach((line)%20%3D%3E%20console.log(line))%3B%0A%20%20%7D%0A%7D%0A%0Afunction%20getLines()%3A%20string%5B%5D%20%7B%0A%09return%20%5B%22%22%5D%0A%7D

Both have the same syntax error, a missing { on the function body.

Dart prints 8 errors, 7 of which are completely useless noise and one is in completely the wrong place (a full 3 lines from where the error actually is).

Typescript prints two - one at the method I messed up on, and one (correctly) at the end brace for that method.

@bwilkerson bwilkerson added type-enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-recovery labels Feb 2, 2016
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed Priority-Medium labels Mar 1, 2016
@bwilkerson
Copy link
Member

@danrubel Another example of poor error recovery that we should look at for Fasta.

@danrubel
Copy link

Agreed. The scanner could have a flag indicating that there were unbalanced { } pairs, then the parser could quickly determine if it should run a special recovery pass over the tokens before the normal parsing begins.

@bwilkerson
Copy link
Member

There's an even stronger signal here, which is that the quotes will be unbalanced if we assume they're part of the string interpolation expression, but balanced if we assume that they're not. That said, it isn't clear whether to assume the missing } should be inserted before the first, third, fifth, etc. ending quote. I suspect that this will be a hard case to recover from well.

@danrubel
Copy link

Um... I don't see any string interpolation in the dartpad example above. Am I missing something?

@bwilkerson
Copy link
Member

Sorry, my mistake. I was confusing two issues.

Yes, we need to do a better job of recovering from mis-matched token pairs.

@srawlins srawlins changed the title Ridiculous number of compiler errors for a missing token. Ridiculous number of compiler errors for a missing open { on top-level Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-recovery area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants