microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.29k stars 12.39k forks source link

identifierCount may not be correct #28534

Open ghost opened 5 years ago

ghost commented 5 years ago

TypeScript Version: 3.2.0-dev.20181114

In parser.ts, there is an identifierCount variable that is incremented every time createIdentifier is called. Unfortunately, not all createIdentifier calls will result in an identifier in the AST, since some may have happened during speculative parsing. It may be necessary to reset identifierCount after speculative parsing fails.

ahejlsberg commented 5 years ago

Just for context, the identifierCount is computed solely for diagnostic reporting purposes. But, you're right, it ought to be saved and restored during speculative parsing.