Fix parsing of private fields (#566)
The computed key is not part of the spec. key for ClassProperties is an Expression Do not parse computed and literal keys for PrivateClassProperties
This commit is contained in:
committed by
Henry Zhu
parent
37793d5be7
commit
69cba43f82
@@ -89,7 +89,6 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
@@ -123,7 +122,6 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 20,
|
||||
@@ -149,4 +147,4 @@
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
class Foo {
|
||||
#p = x
|
||||
[#m] () {}
|
||||
#[m] = 1
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ; (3:10)",
|
||||
"throws": "Unexpected token (3:3)",
|
||||
"plugins": [
|
||||
"classProperties",
|
||||
"classPrivateProperties"
|
||||
4
test/fixtures/experimental/class-private-properties/failure-method/actual.js
vendored
Normal file
4
test/fixtures/experimental/class-private-properties/failure-method/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
#p = x
|
||||
#m () {}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ; (3:5)",
|
||||
"plugins": ["classProperties", "classPrivateProperties"]
|
||||
}
|
||||
3
test/fixtures/experimental/class-private-properties/failure-numeric-literal/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-private-properties/failure-numeric-literal/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
#2 = y
|
||||
}
|
||||
7
test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json
vendored
Normal file
7
test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:3)",
|
||||
"plugins": [
|
||||
"classProperties",
|
||||
"classPrivateProperties"
|
||||
]
|
||||
}
|
||||
3
test/fixtures/experimental/class-private-properties/failure-string-literal/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-private-properties/failure-string-literal/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
#"p" = x
|
||||
}
|
||||
7
test/fixtures/experimental/class-private-properties/failure-string-literal/options.json
vendored
Normal file
7
test/fixtures/experimental/class-private-properties/failure-string-literal/options.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:3)",
|
||||
"plugins": [
|
||||
"classProperties",
|
||||
"classPrivateProperties"
|
||||
]
|
||||
}
|
||||
@@ -89,7 +89,6 @@
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 11,
|
||||
@@ -123,7 +122,6 @@
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
@@ -207,7 +205,6 @@
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 32,
|
||||
@@ -260,7 +257,6 @@
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 40,
|
||||
@@ -305,4 +301,4 @@
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
class Point {
|
||||
#x;
|
||||
#y;
|
||||
|
||||
constructor(x = 0, y = 0) {
|
||||
#x = +x;
|
||||
#y = +y;
|
||||
}
|
||||
|
||||
get x() { return this.#x }
|
||||
set x(value) { this.#x = +value }
|
||||
|
||||
get y() { return this.#y }
|
||||
set y(value) { this.#y = +value }
|
||||
|
||||
equals(p) { return this.#x === p.#x && this.#y === p.#y }
|
||||
|
||||
toString() { return `Point<${ this.#x },${ this.#y }>` }
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -89,7 +89,6 @@
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
@@ -123,7 +122,6 @@
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 27,
|
||||
@@ -1623,4 +1621,4 @@
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user