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:
Daniel Tschinder
2017-06-06 17:42:07 +02:00
committed by Henry Zhu
parent 37793d5be7
commit 69cba43f82
18 changed files with 38 additions and 1919 deletions

View File

@@ -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": []
}
}
}

View File

@@ -1,5 +1,5 @@
{
"throws": "Unexpected token, expected ; (3:10)",
"throws": "Unexpected token (3:3)",
"plugins": [
"classProperties",
"classPrivateProperties"

View File

@@ -0,0 +1,4 @@
class Foo {
#p = x
#m () {}
}

View File

@@ -1,3 +1,4 @@
{
"throws": "Unexpected token, expected ; (3:5)",
"plugins": ["classProperties", "classPrivateProperties"]
}

View File

@@ -0,0 +1,3 @@
class Foo {
#2 = y
}

View File

@@ -0,0 +1,7 @@
{
"throws": "Unexpected token (2:3)",
"plugins": [
"classProperties",
"classPrivateProperties"
]
}

View File

@@ -0,0 +1,3 @@
class Foo {
#"p" = x
}

View File

@@ -0,0 +1,7 @@
{
"throws": "Unexpected token (2:3)",
"plugins": [
"classProperties",
"classPrivateProperties"
]
}

View File

@@ -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": []
}
}
}

View File

@@ -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 }>` }
}

View File

@@ -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": []
}
}
}