hermes-parser 0.29.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -784,12 +784,12 @@ function mapMatchExpression(node) {
|
|
|
784
784
|
hasWildcard,
|
|
785
785
|
analyses
|
|
786
786
|
} = analyzeCases(cases);
|
|
787
|
-
const isSimpleArgument = calculateSimpleArgument(argument);
|
|
787
|
+
const isSimpleArgument = !hasBindings && calculateSimpleArgument(argument);
|
|
788
788
|
const genRoot = !isSimpleArgument ? genIdent() : null;
|
|
789
789
|
const root = genRoot == null ? argument : genRoot; // No bindings and a simple argument means we can use nested conditional
|
|
790
790
|
// expressions.
|
|
791
791
|
|
|
792
|
-
if (
|
|
792
|
+
if (isSimpleArgument) {
|
|
793
793
|
const wildcardAnalaysis = hasWildcard ? analyses.pop() : null;
|
|
794
794
|
const lastBody = wildcardAnalaysis != null ? wildcardAnalaysis.body : (0, _Builders.iife)([fallthroughError((0, _astNodeMutationHelpers.shallowCloneNode)(root))]);
|
|
795
795
|
return analyses.reverse().reduce((acc, analysis) => {
|
|
@@ -886,11 +886,12 @@ function mapMatchStatement(node) {
|
|
|
886
886
|
cases
|
|
887
887
|
} = node;
|
|
888
888
|
const {
|
|
889
|
+
hasBindings,
|
|
889
890
|
hasWildcard,
|
|
890
891
|
analyses
|
|
891
892
|
} = analyzeCases(cases);
|
|
892
893
|
const topLabel = genIdent();
|
|
893
|
-
const isSimpleArgument = calculateSimpleArgument(argument);
|
|
894
|
+
const isSimpleArgument = !hasBindings && calculateSimpleArgument(argument);
|
|
894
895
|
const genRoot = !isSimpleArgument ? genIdent() : null;
|
|
895
896
|
const root = genRoot == null ? argument : genRoot;
|
|
896
897
|
const statements = [];
|
|
@@ -701,13 +701,13 @@ function mapMatchExpression(node: MatchExpression): Expression {
|
|
|
701
701
|
const {argument, cases} = node;
|
|
702
702
|
const {hasBindings, hasWildcard, analyses} = analyzeCases(cases);
|
|
703
703
|
|
|
704
|
-
const isSimpleArgument = calculateSimpleArgument(argument);
|
|
704
|
+
const isSimpleArgument = !hasBindings && calculateSimpleArgument(argument);
|
|
705
705
|
const genRoot: Identifier | null = !isSimpleArgument ? genIdent() : null;
|
|
706
706
|
const root: Expression = genRoot == null ? argument : genRoot;
|
|
707
707
|
|
|
708
708
|
// No bindings and a simple argument means we can use nested conditional
|
|
709
709
|
// expressions.
|
|
710
|
-
if (
|
|
710
|
+
if (isSimpleArgument) {
|
|
711
711
|
const wildcardAnalaysis = hasWildcard ? analyses.pop() : null;
|
|
712
712
|
const lastBody =
|
|
713
713
|
wildcardAnalaysis != null
|
|
@@ -798,10 +798,10 @@ function mapMatchExpression(node: MatchExpression): Expression {
|
|
|
798
798
|
*/
|
|
799
799
|
function mapMatchStatement(node: MatchStatement): Statement {
|
|
800
800
|
const {argument, cases} = node;
|
|
801
|
-
const {hasWildcard, analyses} = analyzeCases(cases);
|
|
801
|
+
const {hasBindings, hasWildcard, analyses} = analyzeCases(cases);
|
|
802
802
|
|
|
803
803
|
const topLabel: Identifier = genIdent();
|
|
804
|
-
const isSimpleArgument = calculateSimpleArgument(argument);
|
|
804
|
+
const isSimpleArgument = !hasBindings && calculateSimpleArgument(argument);
|
|
805
805
|
const genRoot: Identifier | null = !isSimpleArgument ? genIdent() : null;
|
|
806
806
|
const root: Expression = genRoot == null ? argument : genRoot;
|
|
807
807
|
|
|
@@ -784,12 +784,12 @@ function mapMatchExpression(node) {
|
|
|
784
784
|
hasWildcard,
|
|
785
785
|
analyses
|
|
786
786
|
} = analyzeCases(cases);
|
|
787
|
-
const isSimpleArgument = calculateSimpleArgument(argument);
|
|
787
|
+
const isSimpleArgument = !hasBindings && calculateSimpleArgument(argument);
|
|
788
788
|
const genRoot = !isSimpleArgument ? genIdent() : null;
|
|
789
789
|
const root = genRoot == null ? argument : genRoot; // No bindings and a simple argument means we can use nested conditional
|
|
790
790
|
// expressions.
|
|
791
791
|
|
|
792
|
-
if (
|
|
792
|
+
if (isSimpleArgument) {
|
|
793
793
|
const wildcardAnalaysis = hasWildcard ? analyses.pop() : null;
|
|
794
794
|
const lastBody = wildcardAnalaysis != null ? wildcardAnalaysis.body : (0, _Builders.iife)([fallthroughError((0, _astNodeMutationHelpers.shallowCloneNode)(root))]);
|
|
795
795
|
return analyses.reverse().reduce((acc, analysis) => {
|
|
@@ -886,11 +886,12 @@ function mapMatchStatement(node) {
|
|
|
886
886
|
cases
|
|
887
887
|
} = node;
|
|
888
888
|
const {
|
|
889
|
+
hasBindings,
|
|
889
890
|
hasWildcard,
|
|
890
891
|
analyses
|
|
891
892
|
} = analyzeCases(cases);
|
|
892
893
|
const topLabel = genIdent();
|
|
893
|
-
const isSimpleArgument = calculateSimpleArgument(argument);
|
|
894
|
+
const isSimpleArgument = !hasBindings && calculateSimpleArgument(argument);
|
|
894
895
|
const genRoot = !isSimpleArgument ? genIdent() : null;
|
|
895
896
|
const root = genRoot == null ? argument : genRoot;
|
|
896
897
|
const statements = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-parser",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "A JavaScript parser built from the Hermes engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git@github.com:facebook/hermes.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"hermes-estree": "0.29.
|
|
12
|
+
"hermes-estree": "0.29.1"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@babel/parser": "7.7.4",
|