[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
223 changed files with 16948 additions and 259 deletions

View File

@ -28,9 +28,9 @@ class Foo {
foo = 0; bar = 1; foo = 0; bar = 1;
#foo; #foo;
#foo = 1; #foo2 = 1;
static #foo; static #foo3;
static #foo = Foo.#foo; static #foo4 = Foo.#foo;
} }
class A1 { class A1 {

View File

@ -27,9 +27,9 @@ class Foo {
foo = 0; foo = 0;
bar = 1; bar = 1;
#foo; #foo;
#foo = 1; #foo2 = 1;
static #foo; static #foo3;
static #foo = Foo.#foo; static #foo4 = Foo.#foo;
} }
class A1 { class A1 {

View File

@ -6,13 +6,13 @@ class Foo {
set foo(bar) {} set foo(bar) {}
async #foo() {} async #foo() {}
#foo() {} #foo2() {}
get #foo() {} get #foo3() {}
set #foo(bar) {} set #foo3(bar) {}
* #foo() {} * #foo4() {}
async * #foo() {} async * #foo5() {}
get #bar() {} get #bar6() {}
set #baz(taz) {} set #baz6(taz) {}
static async foo() {} static async foo() {}
static foo() {} static foo() {}
@ -23,13 +23,13 @@ class Foo {
static * foo() {} static * foo() {}
static async * foo() {} static async * foo() {}
static #foo() {} static #foo7() {}
static async #foo() {} static async #foo8() {}
static ["foo"]() {} static ["foo"]() {}
static get #foo() {} static get #foo9() {}
static set #foo(taz) {} static set #foo9(taz) {}
static * #foo() {} static * #foo10() {}
static async * #foo() {} static async * #foo11() {}
get get
() {} () {}

View File

@ -11,19 +11,19 @@ class Foo {
async #foo() {} async #foo() {}
#foo() {} #foo2() {}
get #foo() {} get #foo3() {}
set #foo(bar) {} set #foo3(bar) {}
*#foo() {} *#foo4() {}
async *#foo() {} async *#foo5() {}
get #bar() {} get #bar6() {}
set #baz(taz) {} set #baz6(taz) {}
static async foo() {} static async foo() {}
@ -41,19 +41,19 @@ class Foo {
static async *foo() {} static async *foo() {}
static #foo() {} static #foo7() {}
static async #foo() {} static async #foo8() {}
static ["foo"]() {} static ["foo"]() {}
static get #foo() {} static get #foo9() {}
static set #foo(taz) {} static set #foo9(taz) {}
static *#foo() {} static *#foo10() {}
static async *#foo() {} static async *#foo11() {}
get() {} get() {}

View File

@ -4,12 +4,14 @@ import type { Options } from "../options";
import type State from "../tokenizer/state"; import type State from "../tokenizer/state";
import type { PluginsMap } from "./index"; import type { PluginsMap } from "./index";
import type ScopeHandler from "../util/scope"; import type ScopeHandler from "../util/scope";
import type ClassScopeHandler from "../util/class-scope";
export default class BaseParser { export default class BaseParser {
// Properties set by constructor in index.js // Properties set by constructor in index.js
options: Options; options: Options;
inModule: boolean; inModule: boolean;
scope: ScopeHandler<*>; scope: ScopeHandler<*>;
classScope: ClassScopeHandler;
plugins: PluginsMap; plugins: PluginsMap;
filename: ?string; filename: ?string;
sawUnambiguousESM: boolean = false; sawUnambiguousESM: boolean = false;

View File

@ -612,15 +612,21 @@ export default class ExpressionParser extends LValParser {
? this.parseIdentifier(true) ? this.parseIdentifier(true)
: this.parseMaybePrivateName(); : this.parseMaybePrivateName();
node.computed = computed; node.computed = computed;
if (
node.property.type === "PrivateName" && if (node.property.type === "PrivateName") {
node.object.type === "Super" if (node.object.type === "Super") {
) {
this.raise(startPos, "Private fields can't be accessed on super"); this.raise(startPos, "Private fields can't be accessed on super");
} }
this.classScope.usePrivateName(
node.property.id.name,
node.property.start,
);
}
if (computed) { if (computed) {
this.expect(tt.bracketR); this.expect(tt.bracketR);
} }
if (state.optionalChainMember) { if (state.optionalChainMember) {
node.optional = optional; node.optional = optional;
return this.finishNode(node, "OptionalMemberExpression"); return this.finishNode(node, "OptionalMemberExpression");

View File

@ -7,6 +7,7 @@ import { getOptions } from "../options";
import StatementParser from "./statement"; import StatementParser from "./statement";
import { SCOPE_ASYNC, SCOPE_PROGRAM } from "../util/scopeflags"; import { SCOPE_ASYNC, SCOPE_PROGRAM } from "../util/scopeflags";
import ScopeHandler from "../util/scope"; import ScopeHandler from "../util/scope";
import ClassScopeHandler from "../util/class-scope";
export type PluginsMap = Map<string, { [string]: any }>; export type PluginsMap = Map<string, { [string]: any }>;
@ -25,6 +26,7 @@ export default class Parser extends StatementParser {
this.options = options; this.options = options;
this.inModule = this.options.sourceType === "module"; this.inModule = this.options.sourceType === "module";
this.scope = new ScopeHandler(this.raise.bind(this), this.inModule); this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
this.classScope = new ClassScopeHandler(this.raise.bind(this));
this.plugins = pluginsMap(this.options.plugins); this.plugins = pluginsMap(this.options.plugins);
this.filename = options.sourceFilename; this.filename = options.sourceFilename;
} }

View File

@ -20,6 +20,11 @@ import {
SCOPE_OTHER, SCOPE_OTHER,
SCOPE_SIMPLE_CATCH, SCOPE_SIMPLE_CATCH,
SCOPE_SUPER, SCOPE_SUPER,
CLASS_ELEMENT_OTHER,
CLASS_ELEMENT_INSTANCE_GETTER,
CLASS_ELEMENT_INSTANCE_SETTER,
CLASS_ELEMENT_STATIC_GETTER,
CLASS_ELEMENT_STATIC_SETTER,
type BindingTypes, type BindingTypes,
} from "../util/scopeflags"; } from "../util/scopeflags";
@ -1171,7 +1176,7 @@ export default class StatementParser extends ExpressionParser {
} }
parseClassBody(constructorAllowsSuper: boolean): N.ClassBody { parseClassBody(constructorAllowsSuper: boolean): N.ClassBody {
this.state.classLevel++; this.classScope.enter();
const state = { hadConstructor: false }; const state = { hadConstructor: false };
let decorators: N.Decorator[] = []; let decorators: N.Decorator[] = [];
@ -1231,7 +1236,7 @@ export default class StatementParser extends ExpressionParser {
); );
} }
this.state.classLevel--; this.classScope.exit();
return this.finishNode(classBody, "ClassBody"); return this.finishNode(classBody, "ClassBody");
} }
@ -1514,7 +1519,15 @@ export default class StatementParser extends ExpressionParser {
prop: N.ClassPrivateProperty, prop: N.ClassPrivateProperty,
) { ) {
this.expectPlugin("classPrivateProperties", prop.key.start); this.expectPlugin("classPrivateProperties", prop.key.start);
classBody.body.push(this.parseClassPrivateProperty(prop));
const node = this.parseClassPrivateProperty(prop);
classBody.body.push(node);
this.classScope.declarePrivateName(
node.key.id.name,
CLASS_ELEMENT_OTHER,
node.key.start,
);
} }
pushClassMethod( pushClassMethod(
@ -1545,8 +1558,8 @@ export default class StatementParser extends ExpressionParser {
isAsync: boolean, isAsync: boolean,
): void { ): void {
this.expectPlugin("classPrivateMethods", method.key.start); this.expectPlugin("classPrivateMethods", method.key.start);
classBody.body.push(
this.parseMethod( const node = this.parseMethod(
method, method,
isGenerator, isGenerator,
isAsync, isAsync,
@ -1554,8 +1567,20 @@ export default class StatementParser extends ExpressionParser {
false, false,
"ClassPrivateMethod", "ClassPrivateMethod",
true, true,
),
); );
classBody.body.push(node);
const kind =
node.kind === "get"
? node.static
? CLASS_ELEMENT_STATIC_GETTER
: CLASS_ELEMENT_INSTANCE_GETTER
: node.kind === "set"
? node.static
? CLASS_ELEMENT_STATIC_SETTER
: CLASS_ELEMENT_INSTANCE_SETTER
: CLASS_ELEMENT_OTHER;
this.classScope.declarePrivateName(node.key.id.name, kind, node.key.start);
} }
// Overridden in typescript.js // Overridden in typescript.js

View File

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

View File

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

View File

@ -0,0 +1,113 @@
// @flow
import {
CLASS_ELEMENT_KIND_ACCESSOR,
CLASS_ELEMENT_FLAG_STATIC,
type ClassElementTypes,
} from "./scopeflags";
export class ClassScope {
// A list of private named declared in the current class
privateNames: Set<string> = new Set();
// A list of private getters of setters without their counterpart
loneAccessors: Map<string, ClassElementTypes> = new Map();
// A list of private names used before being defined, mapping to
// their position.
undefinedPrivateNames: Map<string, number> = new Map();
}
type raiseFunction = (number, string) => void;
export default class ClassScopeHandler {
stack: Array<ClassScope> = [];
raise: raiseFunction;
undefinedPrivateNames: Map<string, number> = new Map();
constructor(raise: raiseFunction) {
this.raise = raise;
}
current(): ClassScope {
return this.stack[this.stack.length - 1];
}
enter() {
this.stack.push(new ClassScope());
}
exit() {
const oldClassScope = this.stack.pop();
// Migrate the usage of not yet defined private names to the outer
// class scope, or raise an error if we reached the top-level scope.
const current = this.current();
// Array.from is needed because this is compiled to an array-like for loop
for (const [name, pos] of Array.from(oldClassScope.undefinedPrivateNames)) {
if (current) {
if (!current.undefinedPrivateNames.has(name)) {
current.undefinedPrivateNames.set(name, pos);
}
} else {
this.raiseUndeclaredPrivateName(name, pos);
}
}
}
declarePrivateName(
name: string,
elementType: ClassElementTypes,
pos: number,
) {
const classScope = this.current();
let redefined = classScope.privateNames.has(name);
if (elementType & CLASS_ELEMENT_KIND_ACCESSOR) {
const accessor = redefined && classScope.loneAccessors.get(name);
if (accessor) {
const oldStatic = accessor & CLASS_ELEMENT_FLAG_STATIC;
const newStatic = elementType & CLASS_ELEMENT_FLAG_STATIC;
const oldKind = accessor & CLASS_ELEMENT_KIND_ACCESSOR;
const newKind = elementType & CLASS_ELEMENT_KIND_ACCESSOR;
// The private name can be duplicated only if it is used by
// two accessors with different kind (get and set), and if
// they have the same placement (static or not).
redefined = oldKind === newKind || oldStatic !== newStatic;
if (!redefined) classScope.loneAccessors.delete(name);
} else if (!redefined) {
classScope.loneAccessors.set(name, elementType);
}
}
if (redefined) {
this.raise(pos, `Duplicate private name #${name}`);
}
classScope.privateNames.add(name);
classScope.undefinedPrivateNames.delete(name);
}
usePrivateName(name: string, pos: number) {
let classScope;
for (classScope of this.stack) {
if (classScope.privateNames.has(name)) return;
}
if (classScope) {
classScope.undefinedPrivateNames.set(name, pos);
} else {
// top-level
this.raiseUndeclaredPrivateName(name, pos);
}
}
raiseUndeclaredPrivateName(name: string, pos: number) {
this.raise(pos, `Private name #${name} is not defined`);
}
}

View File

@ -43,6 +43,7 @@ export default class ScopeHandler<IScope: Scope = Scope> {
raise: raiseFunction; raise: raiseFunction;
inModule: boolean; inModule: boolean;
undefinedExports: Map<string, number> = new Map(); undefinedExports: Map<string, number> = new Map();
undefinedPrivateNames: Map<string, number> = new Map();
constructor(raise: raiseFunction, inModule: boolean) { constructor(raise: raiseFunction, inModule: boolean) {
this.raise = raise; this.raise = raise;

View File

@ -84,3 +84,23 @@ export type BindingTypes =
| typeof BIND_TS_ENUM | typeof BIND_TS_ENUM
| typeof BIND_TS_AMBIENT | typeof BIND_TS_AMBIENT
| typeof BIND_TS_NAMESPACE; | typeof BIND_TS_NAMESPACE;
// prettier-ignore
export const CLASS_ELEMENT_FLAG_STATIC = 0b1_00,
CLASS_ELEMENT_KIND_GETTER = 0b0_10,
CLASS_ELEMENT_KIND_SETTER = 0b0_01,
CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER;
// prettier-ignore
export const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC,
CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC,
CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER,
CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER,
CLASS_ELEMENT_OTHER = 0;
export type ClassElementTypes =
| typeof CLASS_ELEMENT_STATIC_GETTER
| typeof CLASS_ELEMENT_STATIC_SETTER
| typeof CLASS_ELEMENT_INSTANCE_GETTER
| typeof CLASS_ELEMENT_INSTANCE_SETTER
| typeof CLASS_ELEMENT_OTHER;

View File

@ -0,0 +1,26 @@
These tests have been generated using the following script:
```js
var feat = {
"field": "#x = 0;",
"method": "#x() {}",
"get": "get #x() {}",
"set": "set #x(_) {}",
};
var placement = {
"static": "static ",
"instance": ""
}
for (var f1 in feat) for (var f2 in feat) for (var p1 in placement) for (var p2 in placement) {
var code = `class A {
${placement[p1]}${feat[f1]}
${placement[p2]}${feat[f2]}
}`;
var name = `${p1}-${f1}-${p2}-${f2}`;
var folder = "packages/babel-parser/test/fixtures/experimental/class-private-names-duplicated/" + name;
if (!fs.existsSync(folder)) fs.mkdirSync(folder);
fs.writeFileSync(folder + "/input.js", code);
}
```

View File

@ -0,0 +1,4 @@
class A {
#x = 0;
#x = 0;
}

View File

@ -0,0 +1,224 @@
{
"type": "File",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateProperty",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x = 0;
get #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,227 @@
{
"type": "File",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:6)"
],
"program": {
"type": "Program",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 13
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,226 @@
{
"type": "File",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 27,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 9
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x = 0;
set #x(_) {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,245 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:6)"
],
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 32,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 12
},
"end": {
"line": 3,
"column": 14
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x = 0;
static #x = 0;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,224 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:9)"
],
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateProperty",
"start": 22,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 16
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 29,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 30,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x = 0;
static get #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,227 @@
{
"type": "File",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:13)"
],
"program": {
"type": "Program",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 20
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 38,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 18
},
"end": {
"line": 3,
"column": 20
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x = 0;
static #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,226 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:9)"
],
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 16
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 29,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 30,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 34,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 16
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x = 0;
static set #x(_) {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,245 @@
{
"type": "File",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:13)"
],
"program": {
"type": "Program",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 21
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 36,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 16
},
"end": {
"line": 3,
"column": 17
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 39,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 19
},
"end": {
"line": 3,
"column": 21
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
#x = 0;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,227 @@
{
"type": "File",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateProperty",
"start": 26,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
get #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,230 @@
{
"type": "File",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:6)"
],
"program": {
"type": "Program",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 26,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 30,
"end": 32,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 35,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 13
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
#x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,229 @@
{
"type": "File",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 26,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 9
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
set #x(_) {}
}

View File

@ -0,0 +1,245 @@
{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 26,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 30,
"end": 32,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 36,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 12
},
"end": {
"line": 3,
"column": 14
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
static #x = 0;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,227 @@
{
"type": "File",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:9)"
],
"program": {
"type": "Program",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateProperty",
"start": 26,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 16
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 38,
"end": 39,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
static get #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,230 @@
{
"type": "File",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:13)"
],
"program": {
"type": "Program",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 26,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 20
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 37,
"end": 39,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 38,
"end": 39,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 42,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 18
},
"end": {
"line": 3,
"column": 20
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
static #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,229 @@
{
"type": "File",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:9)"
],
"program": {
"type": "Program",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 26,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 16
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 38,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 16
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
get #x() {}
static set #x(_) {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,248 @@
{
"type": "File",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:13)"
],
"program": {
"type": "Program",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 26,
"end": 45,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 21
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 37,
"end": 39,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 38,
"end": 39,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 40,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 16
},
"end": {
"line": 3,
"column": 17
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 43,
"end": 45,
"loc": {
"start": {
"line": 3,
"column": 19
},
"end": {
"line": 3,
"column": 21
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,226 @@
{
"type": "File",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateProperty",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x() {}
get #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,229 @@
{
"type": "File",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:6)"
],
"program": {
"type": "Program",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 13
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,228 @@
{
"type": "File",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 27,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 9
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x() {}
set #x(_) {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,247 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:6)"
],
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 32,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 12
},
"end": {
"line": 3,
"column": 14
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x() {}
static #x = 0;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,226 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:9)"
],
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateProperty",
"start": 22,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 16
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 29,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 30,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x() {}
static get #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,229 @@
{
"type": "File",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:13)"
],
"program": {
"type": "Program",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 20
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 38,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 18
},
"end": {
"line": 3,
"column": 20
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x() {}
static #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,228 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:9)"
],
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 16
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 29,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 30,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 34,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 16
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
#x() {}
static set #x(_) {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,247 @@
{
"type": "File",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:13)"
],
"program": {
"type": "Program",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 9
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 22,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 21
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 36,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 16
},
"end": {
"line": 3,
"column": 17
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 39,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 19
},
"end": {
"line": 3,
"column": 21
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
set #x(_) {}
#x = 0;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,245 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateProperty",
"start": 27,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 27,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 28,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 32,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
set #x(_) {}
get #x() {}
}

View File

@ -0,0 +1,245 @@
{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 27,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 32,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 36,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 13
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
set #x(_) {}
#x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,247 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:2)"
],
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 27,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 27,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 28,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 32,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 9
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
set #x(_) {}
set #x(_) {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,266 @@
{
"type": "File",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:6)"
],
"program": {
"type": "Program",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 27,
"end": 39,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 32,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 37,
"end": 39,
"loc": {
"start": {
"line": 3,
"column": 12
},
"end": {
"line": 3,
"column": 14
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
set #x(_) {}
static #x = 0;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

View File

@ -0,0 +1,245 @@
{
"type": "File",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"errors": [
"SyntaxError: Duplicate private name #x (3:9)"
],
"program": {
"type": "Program",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 12,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 16,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "_"
},
"name": "_"
}
],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassPrivateProperty",
"start": 27,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 16
}
},
"static": true,
"key": {
"type": "PrivateName",
"start": 34,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 35,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"value": {
"type": "NumericLiteral",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,4 @@
class A {
set #x(_) {}
static get #x() {}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "classPrivateMethods"]
}

Some files were not shown because too many files have changed in this diff Show More