[parser] Disallow duplicate and undeclared private names (#10456)

* [parser] Add private names tracking to Scope

- Disallow duplicate private names
- Disallow undeclared private names

* Update tests

* Test all possible duplications

* Test undeclared private names

* Better error message for top-level private names

* Fix flow

* Update test262 whitelist

* Update fixtures

* Update flow whitelist

* Remove old output.json

* Move ClassScopeHandler to a separate class

* Make the code readable
This commit is contained in:
Nicolò Ribaudo
2020-01-10 02:22:05 +01:00
committed by GitHub
parent 9f148a1603
commit 771c730fda
223 changed files with 16948 additions and 259 deletions

View File

@@ -391,14 +391,8 @@ export default class Tokenizer extends LocationParser {
}
if (
(this.hasPlugin("classPrivateProperties") ||
this.hasPlugin("classPrivateMethods")) &&
this.state.classLevel > 0
) {
++this.state.pos;
this.finishToken(tt.hash);
return;
} else if (
this.hasPlugin("classPrivateProperties") ||
this.hasPlugin("classPrivateMethods") ||
this.getPluginOption("pipelineOperator", "proposal") === "smart"
) {
this.finishOp(tt.hash, 1);

View File

@@ -77,9 +77,6 @@ export default class State {
soloAwait: boolean = false;
inFSharpPipelineDirectBody: boolean = false;
// Check whether we are in a (nested) class or not.
classLevel: number = 0;
// Labels in scope.
labels: Array<{
kind: ?("loop" | "switch"),