Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Ignore ClassPrivateProperty fields if empty.
Browse files Browse the repository at this point in the history
Summary:
Two fields were copy/pasted incorrectly.
Add a check to make sure that doesn't happen again.

Reviewed By: tmikov

Differential Revision: D27086448

fbshipit-source-id: f36dfdbafd1ecbf04382f6739323ba49d812aacd
  • Loading branch information
avp authored and facebook-github-bot committed Mar 20, 2021
1 parent d1077ce commit 7fadf8f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
4 changes: 2 additions & 2 deletions include/hermes/AST/ESTree.def
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ ESTREE_NODE_6_ARGS(
NodeBoolean, declare, false,
NodePtr, variance, true,
NodePtr, typeAnnotation, true)
ESTREE_IGNORE_IF_EMPTY(ClassProperty, variance)
ESTREE_IGNORE_IF_EMPTY(ClassProperty, typeAnnotation)
ESTREE_IGNORE_IF_EMPTY(ClassPrivateProperty, variance)
ESTREE_IGNORE_IF_EMPTY(ClassPrivateProperty, typeAnnotation)

ESTREE_NODE_5_ARGS(
MethodDefinition, Base,
Expand Down
5 changes: 4 additions & 1 deletion lib/AST/ESTreeJSONDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ class ESTreeJSONDumper {
#define ESTREE_NODE_6_ARGS(NAME, ...)
#define ESTREE_NODE_7_ARGS(NAME, ...)
#define ESTREE_NODE_8_ARGS(NAME, ...)
#define ESTREE_IGNORE_IF_EMPTY(NAME, FIELD) \
#define ESTREE_IGNORE_IF_EMPTY(NAME, FIELD) \
assert( \
!ignoredEmptyFields_[#NAME].count(#FIELD) && \
"duplicate ignored fields"); \
ignoredEmptyFields_[#NAME].insert(#FIELD);
#include "hermes/AST/ESTree.def"
}
Expand Down
3 changes: 0 additions & 3 deletions test/Parser/flow/private-property-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class A {
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": {
// CHECK-NEXT: "type": "TypeAnnotation",
// CHECK-NEXT: "typeAnnotation": {
Expand All @@ -52,7 +51,6 @@ class A {
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": {
// CHECK-NEXT: "type": "TypeAnnotation",
// CHECK-NEXT: "typeAnnotation": {
Expand All @@ -74,7 +72,6 @@ class A {
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": {
// CHECK-NEXT: "type": "TypeAnnotation",
// CHECK-NEXT: "typeAnnotation": {
Expand Down
26 changes: 7 additions & 19 deletions test/Parser/private-property-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

// RUN: %hermes -dump-ast --pretty-json %s | %FileCheck %s --match-full-lines
// RUN: %hermes -dump-ast -pretty-json %s | %FileCheck %s --match-full-lines

// CHECK-LABEL: {
// CHECK-NEXT: "type": "Program",
Expand All @@ -32,9 +32,7 @@ class A {
// CHECK-NEXT: },
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": null
// CHECK-NEXT: "declare": false
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
Expand Down Expand Up @@ -62,9 +60,7 @@ class A {
// CHECK-NEXT: },
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": null
// CHECK-NEXT: "declare": false
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "type": "ClassPrivateProperty",
Expand All @@ -74,9 +70,7 @@ class A {
// CHECK-NEXT: },
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": null
// CHECK-NEXT: "declare": false
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
Expand All @@ -103,9 +97,7 @@ class A {
// CHECK-NEXT: },
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": null
// CHECK-NEXT: "declare": false
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
Expand Down Expand Up @@ -209,9 +201,7 @@ class A {
// CHECK-NEXT: },
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": null
// CHECK-NEXT: "declare": false
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "type": "MethodDefinition",
Expand Down Expand Up @@ -371,9 +361,7 @@ class A {
// CHECK-NEXT: },
// CHECK-NEXT: "value": null,
// CHECK-NEXT: "static": false,
// CHECK-NEXT: "declare": false,
// CHECK-NEXT: "variance": null,
// CHECK-NEXT: "typeAnnotation": null
// CHECK-NEXT: "declare": false
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "type": "MethodDefinition",
Expand Down

0 comments on commit 7fadf8f

Please sign in to comment.