fix: disallow all parenthesized pattern except parsing LHS (#12327)
* fix: disallow all parenthesized pattern except parsing LHS * fix: forStatement requires LHS * simplify toAssignable * add more test cases * fix: pass through isLHS on object property and assignment expression * fix: record parenthesized identifier error for LHS * remove duplicated skipped tests * fix: do not record errors on ancestry arrow head * Update packages/babel-parser/src/util/expression-scope.js Co-authored-by: Brian Ng <bng412@gmail.com> Co-authored-by: Brian Ng <bng412@gmail.com>
This commit is contained in:
parent
08c7280167
commit
5bbad8936b
@ -278,7 +278,7 @@ export default class ExpressionParser extends LValParser {
|
||||
node.operator = operator;
|
||||
|
||||
if (this.match(tt.eq)) {
|
||||
node.left = this.toAssignable(left);
|
||||
node.left = this.toAssignable(left, /* isLHS */ true);
|
||||
refExpressionErrors.doubleProto = -1; // reset because double __proto__ is valid in assignment expression
|
||||
} else {
|
||||
node.left = left;
|
||||
@ -842,7 +842,6 @@ export default class ExpressionParser extends LValParser {
|
||||
nodeForExtra?: ?N.Node,
|
||||
): $ReadOnlyArray<?N.Expression> {
|
||||
const elts = [];
|
||||
let innerParenStart;
|
||||
let first = true;
|
||||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||||
this.state.inFSharpPipelineDirectBody = false;
|
||||
@ -875,12 +874,6 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
}
|
||||
|
||||
// we need to make sure that if this is an async arrow functions,
|
||||
// that we don't allow inner parens inside the params
|
||||
if (this.match(tt.parenL) && !innerParenStart) {
|
||||
innerParenStart = this.state.start;
|
||||
}
|
||||
|
||||
elts.push(
|
||||
this.parseExprListItem(
|
||||
false,
|
||||
@ -891,11 +884,6 @@ export default class ExpressionParser extends LValParser {
|
||||
);
|
||||
}
|
||||
|
||||
// we found an async arrow function so let's not allow any inner parens
|
||||
if (possibleAsyncArrow && innerParenStart && this.shouldParseAsyncArrow()) {
|
||||
this.unexpected();
|
||||
}
|
||||
|
||||
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
||||
|
||||
return elts;
|
||||
@ -1421,12 +1409,6 @@ export default class ExpressionParser extends LValParser {
|
||||
) {
|
||||
this.expressionScope.validateAsPattern();
|
||||
this.expressionScope.exit();
|
||||
for (const param of exprList) {
|
||||
if (param.extra && param.extra.parenthesized) {
|
||||
this.unexpected(param.extra.parenStart);
|
||||
}
|
||||
}
|
||||
|
||||
this.parseArrowExpression(arrowNode, exprList, false);
|
||||
return arrowNode;
|
||||
}
|
||||
@ -2056,7 +2038,7 @@ export default class ExpressionParser extends LValParser {
|
||||
params: N.Expression[],
|
||||
trailingCommaPos: ?number,
|
||||
): void {
|
||||
node.params = this.toAssignableList(params, trailingCommaPos);
|
||||
node.params = this.toAssignableList(params, trailingCommaPos, false);
|
||||
}
|
||||
|
||||
parseFunctionBodyAndFinish(
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// @flow
|
||||
|
||||
/*:: declare var invariant; */
|
||||
import * as charCodes from "charcodes";
|
||||
import { types as tt, type TokenType } from "../tokenizer/types";
|
||||
import type {
|
||||
@ -24,7 +25,7 @@ import { type BindingTypes, BIND_NONE } from "../util/scopeflags";
|
||||
import { ExpressionErrors } from "./util";
|
||||
import { Errors } from "./error";
|
||||
|
||||
const unwrapParenthesizedExpression = (node: Node) => {
|
||||
const unwrapParenthesizedExpression = (node: Node): Node => {
|
||||
return node.type === "ParenthesizedExpression"
|
||||
? unwrapParenthesizedExpression(node.expression)
|
||||
: node;
|
||||
@ -51,19 +52,45 @@ export default class LValParser extends NodeUtils {
|
||||
+parseDecorator: () => Decorator;
|
||||
*/
|
||||
|
||||
// Convert existing expression atom to assignable pattern
|
||||
// if possible.
|
||||
// NOTE: There is a corresponding "isAssignable" method in flow.js.
|
||||
// When this one is updated, please check if also that one needs to be updated.
|
||||
/**
|
||||
* Convert existing expression atom to assignable pattern
|
||||
* if possible. Also checks invalid destructuring targets:
|
||||
|
||||
toAssignable(node: Node): Node {
|
||||
- Parenthesized Destructuring patterns
|
||||
- RestElement is not the last element
|
||||
- Missing `=` in assignment pattern
|
||||
|
||||
NOTE: There is a corresponding "isAssignable" method in flow.js.
|
||||
When this one is updated, please check if also that one needs to be updated.
|
||||
|
||||
* @param {Node} node The expression atom
|
||||
* @param {boolean} [isLHS=false] Whether we are parsing a LeftHandSideExpression. If isLHS is `true`, the following cases are allowed:
|
||||
`[(a)] = [0]`, `[(a.b)] = [0]`
|
||||
|
||||
* @returns {Node} The converted assignable pattern
|
||||
* @memberof LValParser
|
||||
*/
|
||||
toAssignable(node: Node, isLHS: boolean = false): Node {
|
||||
let parenthesized = undefined;
|
||||
if (node.type === "ParenthesizedExpression" || node.extra?.parenthesized) {
|
||||
parenthesized = unwrapParenthesizedExpression(node);
|
||||
if (
|
||||
parenthesized.type !== "Identifier" &&
|
||||
parenthesized.type !== "MemberExpression"
|
||||
) {
|
||||
if (isLHS) {
|
||||
// an LHS can be reinterpreted to a binding pattern but not vice versa.
|
||||
// therefore a parenthesized identifier is ambiguous until we are sure it is an assignment expression
|
||||
// i.e. `([(a) = []] = []) => {}`
|
||||
// see also `recordParenthesizedIdentifierError` signature in packages/babel-parser/src/util/expression-scope.js
|
||||
if (parenthesized.type === "Identifier") {
|
||||
this.expressionScope.recordParenthesizedIdentifierError(
|
||||
node.start,
|
||||
Errors.InvalidParenthesizedAssignment,
|
||||
);
|
||||
} else if (parenthesized.type !== "MemberExpression") {
|
||||
// A parenthesized member expression can be in LHS but not in pattern.
|
||||
// If the LHS is later interpreted as a pattern, `checkLVal` will throw for member expression binding
|
||||
// i.e. `([(a.b) = []] = []) => {}`
|
||||
this.raise(node.start, Errors.InvalidParenthesizedAssignment);
|
||||
}
|
||||
} else {
|
||||
this.raise(node.start, Errors.InvalidParenthesizedAssignment);
|
||||
}
|
||||
}
|
||||
@ -84,7 +111,7 @@ export default class LValParser extends NodeUtils {
|
||||
) {
|
||||
const prop = node.properties[i];
|
||||
const isLast = i === last;
|
||||
this.toAssignableObjectExpressionProp(prop, isLast);
|
||||
this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
|
||||
|
||||
if (
|
||||
isLast &&
|
||||
@ -97,7 +124,7 @@ export default class LValParser extends NodeUtils {
|
||||
break;
|
||||
|
||||
case "ObjectProperty":
|
||||
this.toAssignable(node.value);
|
||||
this.toAssignable(node.value, isLHS);
|
||||
break;
|
||||
|
||||
case "SpreadElement": {
|
||||
@ -105,13 +132,13 @@ export default class LValParser extends NodeUtils {
|
||||
|
||||
node.type = "RestElement";
|
||||
const arg = node.argument;
|
||||
this.toAssignable(arg);
|
||||
this.toAssignable(arg, isLHS);
|
||||
break;
|
||||
}
|
||||
|
||||
case "ArrayExpression":
|
||||
node.type = "ArrayPattern";
|
||||
this.toAssignableList(node.elements, node.extra?.trailingComma);
|
||||
this.toAssignableList(node.elements, node.extra?.trailingComma, isLHS);
|
||||
break;
|
||||
|
||||
case "AssignmentExpression":
|
||||
@ -121,11 +148,12 @@ export default class LValParser extends NodeUtils {
|
||||
|
||||
node.type = "AssignmentPattern";
|
||||
delete node.operator;
|
||||
this.toAssignable(node.left);
|
||||
this.toAssignable(node.left, isLHS);
|
||||
break;
|
||||
|
||||
case "ParenthesizedExpression":
|
||||
this.toAssignable(((parenthesized: any): Expression));
|
||||
/*::invariant (parenthesized !== undefined) */
|
||||
this.toAssignable(parenthesized, isLHS);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -135,7 +163,11 @@ export default class LValParser extends NodeUtils {
|
||||
return node;
|
||||
}
|
||||
|
||||
toAssignableObjectExpressionProp(prop: Node, isLast: boolean) {
|
||||
toAssignableObjectExpressionProp(
|
||||
prop: Node,
|
||||
isLast: boolean,
|
||||
isLHS: boolean,
|
||||
) {
|
||||
if (prop.type === "ObjectMethod") {
|
||||
const error =
|
||||
prop.kind === "get" || prop.kind === "set"
|
||||
@ -148,7 +180,7 @@ export default class LValParser extends NodeUtils {
|
||||
} else if (prop.type === "SpreadElement" && !isLast) {
|
||||
this.raiseRestNotLast(prop.start);
|
||||
} else {
|
||||
this.toAssignable(prop);
|
||||
this.toAssignable(prop, isLHS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,6 +189,7 @@ export default class LValParser extends NodeUtils {
|
||||
toAssignableList(
|
||||
exprList: Expression[],
|
||||
trailingCommaPos?: ?number,
|
||||
isLHS: boolean,
|
||||
): $ReadOnlyArray<Pattern> {
|
||||
let end = exprList.length;
|
||||
if (end) {
|
||||
@ -165,8 +198,9 @@ export default class LValParser extends NodeUtils {
|
||||
--end;
|
||||
} else if (last?.type === "SpreadElement") {
|
||||
last.type = "RestElement";
|
||||
const arg = last.argument;
|
||||
this.toAssignable(arg);
|
||||
let arg = last.argument;
|
||||
this.toAssignable(arg, isLHS);
|
||||
arg = unwrapParenthesizedExpression(arg);
|
||||
if (
|
||||
arg.type !== "Identifier" &&
|
||||
arg.type !== "MemberExpression" &&
|
||||
@ -186,7 +220,7 @@ export default class LValParser extends NodeUtils {
|
||||
for (let i = 0; i < end; i++) {
|
||||
const elt = exprList[i];
|
||||
if (elt) {
|
||||
this.toAssignable(elt);
|
||||
this.toAssignable(elt, isLHS);
|
||||
if (elt.type === "RestElement") {
|
||||
this.raiseRestNotLast(elt.start);
|
||||
}
|
||||
|
||||
@ -528,7 +528,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
const refExpressionErrors = new ExpressionErrors();
|
||||
const init = this.parseExpression(true, refExpressionErrors);
|
||||
if (this.match(tt._in) || this.isContextual("of")) {
|
||||
this.toAssignable(init);
|
||||
this.toAssignable(init, /* isLHS */ true);
|
||||
const description = this.isContextual("of")
|
||||
? "for-of statement"
|
||||
: "for-in statement";
|
||||
|
||||
@ -341,23 +341,23 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return (node: any);
|
||||
}
|
||||
|
||||
toAssignable(node: N.Node): N.Node {
|
||||
toAssignable(node: N.Node, isLHS: boolean = false): N.Node {
|
||||
if (isSimpleProperty(node)) {
|
||||
this.toAssignable(node.value);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
return super.toAssignable(node);
|
||||
return super.toAssignable(node, isLHS);
|
||||
}
|
||||
|
||||
toAssignableObjectExpressionProp(prop: N.Node, isLast: boolean) {
|
||||
toAssignableObjectExpressionProp(prop: N.Node, ...args) {
|
||||
if (prop.kind === "get" || prop.kind === "set") {
|
||||
throw this.raise(prop.key.start, Errors.PatternHasAccessor);
|
||||
} else if (prop.method) {
|
||||
throw this.raise(prop.key.start, Errors.PatternHasMethod);
|
||||
} else {
|
||||
super.toAssignableObjectExpressionProp(prop, isLast);
|
||||
super.toAssignableObjectExpressionProp(prop, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1955,6 +1955,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// has not been converted yet.
|
||||
((node.params: any): N.Expression[]),
|
||||
node.extra?.trailingComma,
|
||||
/* isLHS */ false,
|
||||
);
|
||||
// Enter scope, as checkParams defines bindings
|
||||
this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
|
||||
@ -2192,11 +2193,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
toAssignable(node: N.Node): N.Node {
|
||||
toAssignable(node: N.Node, isLHS: boolean = false): N.Node {
|
||||
if (node.type === "TypeCastExpression") {
|
||||
return super.toAssignable(this.typeCastToParameter(node));
|
||||
return super.toAssignable(this.typeCastToParameter(node), isLHS);
|
||||
} else {
|
||||
return super.toAssignable(node);
|
||||
return super.toAssignable(node, isLHS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2204,6 +2205,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
toAssignableList(
|
||||
exprList: N.Expression[],
|
||||
trailingCommaPos?: ?number,
|
||||
isLHS: boolean,
|
||||
): $ReadOnlyArray<N.Pattern> {
|
||||
for (let i = 0; i < exprList.length; i++) {
|
||||
const expr = exprList[i];
|
||||
@ -2211,7 +2213,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
exprList[i] = this.typeCastToParameter(expr);
|
||||
}
|
||||
}
|
||||
return super.toAssignableList(exprList, trailingCommaPos);
|
||||
return super.toAssignableList(exprList, trailingCommaPos, isLHS);
|
||||
}
|
||||
|
||||
// this is a list of nodes, from something like a call expression, we need to filter the
|
||||
|
||||
@ -2596,19 +2596,19 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return param;
|
||||
}
|
||||
|
||||
toAssignable(node: N.Node): N.Node {
|
||||
toAssignable(node: N.Node, isLHS: boolean = false): N.Node {
|
||||
switch (node.type) {
|
||||
case "TSTypeCastExpression":
|
||||
return super.toAssignable(this.typeCastToParameter(node));
|
||||
return super.toAssignable(this.typeCastToParameter(node), isLHS);
|
||||
case "TSParameterProperty":
|
||||
return super.toAssignable(node);
|
||||
return super.toAssignable(node, isLHS);
|
||||
case "TSAsExpression":
|
||||
case "TSNonNullExpression":
|
||||
case "TSTypeAssertion":
|
||||
node.expression = this.toAssignable(node.expression);
|
||||
node.expression = this.toAssignable(node.expression, isLHS);
|
||||
return node;
|
||||
default:
|
||||
return super.toAssignable(node);
|
||||
return super.toAssignable(node, isLHS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ some expression scopes and thrown later when we know what the ambigous pattern i
|
||||
- AwaitBindingIdentifier
|
||||
- AwaitExpressionFormalParameter
|
||||
- YieldInParameter
|
||||
- InvalidParenthesizedAssignment when parenthesized is an identifier
|
||||
|
||||
There are four different expression scope
|
||||
- Expression
|
||||
@ -130,6 +131,41 @@ export default class ExpressionScopeHandler {
|
||||
/* eslint-disable @babel/development-internal/dry-error-messages */
|
||||
this.raise(pos, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record parenthesized identifier errors
|
||||
*
|
||||
* A parenthesized identifier in LHS can be ambiguous because the assignment
|
||||
* can be transformed to an assignable later, but not vice versa:
|
||||
* For example, in `([(a) = []] = []) => {}`, we think `(a) = []` is an LHS in `[(a) = []]`,
|
||||
* an LHS within `[(a) = []] = []`. However the LHS chain is then transformed by toAssignable,
|
||||
* and we should throw assignment `(a)`, which is only valid in LHS. Hence we record the
|
||||
* location of parenthesized `(a)` to current scope if it is one of MaybeArrowParameterDeclaration
|
||||
* and MaybeAsyncArrowParameterDeclaration
|
||||
*
|
||||
* Unlike `recordParameterInitializerError`, we don't record to ancestry scope because we
|
||||
* validate arrow head parsing scope before exit, and then the LHS will be unambiguous:
|
||||
* For example, in `( x = ( [(a) = []] = [] ) ) => {}`, we should not record `(a)` in `( x = ... ) =>`
|
||||
* arrow scope because when we finish parsing `( [(a) = []] = [] )`, it is an unambiguous assignment
|
||||
* expression and can not be cast to pattern
|
||||
* @param {number} pos
|
||||
* @param {string} message
|
||||
* @returns {void}
|
||||
* @memberof ExpressionScopeHandler
|
||||
*/
|
||||
recordParenthesizedIdentifierError(pos: number, message: string): void {
|
||||
const { stack } = this;
|
||||
const scope: ExpressionScope = stack[stack.length - 1];
|
||||
if (scope.isCertainlyParameterDeclaration()) {
|
||||
this.raise(pos, message);
|
||||
} else if (scope.canBeArrowParameterDeclaration()) {
|
||||
/*:: invariant(scope instanceof ArrowHeadParsingScope) */
|
||||
scope.recordDeclarationError(pos, message);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Record likely async arrow parameter errors
|
||||
*
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
([...(a)]) => {}
|
||||
@ -0,0 +1,54 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:5)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":1,"end":9,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":9}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":2,"end":8,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":8}},
|
||||
"argument": {
|
||||
"type": "ParenthesizedExpression",
|
||||
"start":5,"end":8,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":8}},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"a"},
|
||||
"name": "a"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"createParenthesizedExpressions": true
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
[...(a)] = []
|
||||
@ -0,0 +1,46 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":1,"end":7,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":7}},
|
||||
"argument": {
|
||||
"type": "ParenthesizedExpression",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7}},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"a"},
|
||||
"name": "a"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":11,"end":13,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":13}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
[...(a.b)] = []
|
||||
@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":1,"end":9,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":9}},
|
||||
"argument": {
|
||||
"type": "ParenthesizedExpression",
|
||||
"start":4,"end":9,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":9}},
|
||||
"expression": {
|
||||
"type": "MemberExpression",
|
||||
"start":5,"end":8,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":8}},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":13,"end":15,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":15}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
52
packages/babel-parser/test/fixtures/es2015/arrow-functions/inner-parens-2/output.json
vendored
Normal file
52
packages/babel-parser/test/fixtures/es2015/arrow-functions/inner-parens-2/output.json
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:5)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":1,"end":2,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"b"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 4
|
||||
},
|
||||
"name": "b"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "NumericLiteral",
|
||||
"start":12,"end":14,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":14}},
|
||||
"extra": {
|
||||
"rawValue": 42,
|
||||
"raw": "42"
|
||||
},
|
||||
"value": 42
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
([ [(a)] = [] ] = []) => {}
|
||||
@ -0,0 +1,74 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:5)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":1,"end":20,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":20}},
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":1,"end":15,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":15}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":3,"end":13,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":13}},
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":3,"end":8,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":8}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 4
|
||||
},
|
||||
"name": "a"
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":11,"end":13,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":13}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":18,"end":20,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":20}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":25,"end":27,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":27}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
([(a) = [] ] = []) => {}
|
||||
@ -0,0 +1,68 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:3)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":1,"end":17,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":17}},
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":1,"end":12,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":12}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":2,"end":10,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":10}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 2
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":8,"end":10,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":10}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":15,"end":17,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":17}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":22,"end":24,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":24}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
([(a)]) => {}
|
||||
@ -0,0 +1,50 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:3)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":1,"end":6,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":6}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 2
|
||||
},
|
||||
"name": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":11,"end":13,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":13}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
({ a: (foo.qux) } = {}) => {}
|
||||
@ -0,0 +1,81 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"errors": [
|
||||
"SyntaxError: Binding member expression (1:7)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":1,"end":22,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":22}},
|
||||
"left": {
|
||||
"type": "ObjectPattern",
|
||||
"start":1,"end":17,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":17}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":3,"end":15,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":15}},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "MemberExpression",
|
||||
"start":7,"end":14,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 6
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":11,"end":14,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":14},"identifierName":"qux"},
|
||||
"name": "qux"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ObjectExpression",
|
||||
"start":20,"end":22,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":22}},
|
||||
"properties": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":27,"end":29,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":29}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
({ a: (foo) } = {}) => {}
|
||||
@ -0,0 +1,71 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:7)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":1,"end":18,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":18}},
|
||||
"left": {
|
||||
"type": "ObjectPattern",
|
||||
"start":1,"end":13,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":3,"end":11,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":11}},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 6
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ObjectExpression",
|
||||
"start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}},
|
||||
"properties": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":23,"end":25,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":25}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
}
|
||||
56
packages/babel-parser/test/fixtures/es2015/arrow-functions/inner-parens/output.json
vendored
Normal file
56
packages/babel-parser/test/fixtures/es2015/arrow-functions/inner-parens/output.json
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:12)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":23,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":23}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":10,"end":23,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":23}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":12,"end":15,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":15},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 11
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":21,"end":23,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":23}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
(x = ([(f) = []] = [])) => {};
|
||||
@ -0,0 +1,79 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":1,"end":22,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":22}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":1,"end":2,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":6,"end":21,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":21}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 5
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":6,"end":16,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":16}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":15,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":15}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":8,"end":9,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":9},"identifierName":"f"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 7
|
||||
},
|
||||
"name": "f"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":13,"end":15,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":15}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":19,"end":21,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":21}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":27,"end":29,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":29}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
([(a) = [] ] = []);
|
||||
@ -0,0 +1,55 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":1,"end":17,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":17}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":1,"end":12,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":12}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":2,"end":10,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":10}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 2
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":8,"end":10,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":10}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":15,"end":17,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":17}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
({ a: (a.b) = (c.d) } = {});
|
||||
@ -0,0 +1,91 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":1,"end":26,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":26}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ObjectPattern",
|
||||
"start":1,"end":21,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":21}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":3,"end":19,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":19}},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "AssignmentPattern",
|
||||
"start":6,"end":19,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":19}},
|
||||
"left": {
|
||||
"type": "MemberExpression",
|
||||
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 6
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "MemberExpression",
|
||||
"start":15,"end":18,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":18}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 14
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"c"},
|
||||
"name": "c"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":17,"end":18,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":18},"identifierName":"d"},
|
||||
"name": "d"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ObjectExpression",
|
||||
"start":24,"end":26,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":26}},
|
||||
"properties": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/destructuring/lhs-parenthesized-object/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/destructuring/lhs-parenthesized-object/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
({ a: (a.b) } = {});
|
||||
68
packages/babel-parser/test/fixtures/es2015/destructuring/lhs-parenthesized-object/output.json
vendored
Normal file
68
packages/babel-parser/test/fixtures/es2015/destructuring/lhs-parenthesized-object/output.json
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":1,"end":18,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":18}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ObjectPattern",
|
||||
"start":1,"end":13,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":3,"end":11,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":11}},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "MemberExpression",
|
||||
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 6
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ObjectExpression",
|
||||
"start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}},
|
||||
"properties": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
[...(a.b)] = [];
|
||||
@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":1,"end":9,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":9}},
|
||||
"argument": {
|
||||
"type": "MemberExpression",
|
||||
"start":5,"end":8,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":8}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 4
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":13,"end":15,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":15}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
(a = function (a) { [(a)] = [0] }) => {}
|
||||
@ -0,0 +1,101 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":1,"end":33,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":33}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":1,"end":2,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"right": {
|
||||
"type": "FunctionExpression",
|
||||
"start":5,"end":33,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":33}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"a"},
|
||||
"name": "a"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":18,"end":33,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":33}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":20,"end":31,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":31}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":20,"end":31,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":31}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 21
|
||||
},
|
||||
"name": "a"
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":28,"end":31,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":31}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "NumericLiteral",
|
||||
"start":29,"end":30,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":30}},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":38,"end":40,"loc":{"start":{"line":1,"column":38},"end":{"line":1,"column":40}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
((a)) => 42
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:1)"
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
async ([(a) = []] = []) => {}
|
||||
@ -0,0 +1,68 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:9)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":22,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":22}},
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":7,"end":17,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":17}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":8,"end":16,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":16}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 8
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":20,"end":22,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":22}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":27,"end":29,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":29}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
async ([ [(a)] = [] ] = []) => {};
|
||||
@ -0,0 +1,74 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":34}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:11)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":34}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":34}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":26,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":26}},
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":7,"end":21,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":21}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}},
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 10
|
||||
},
|
||||
"name": "a"
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":17,"end":19,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":24,"end":26,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":26}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":31,"end":33,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":33}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:18)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":29,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":29}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":10,"end":29,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":29}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":18,"end":21,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":21},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 17
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":27,"end":29,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":29}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
async ([(a.b) = []] = []) => {}
|
||||
@ -0,0 +1,78 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||
"errors": [
|
||||
"SyntaxError: Binding member expression (1:9)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":24,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":24}},
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":7,"end":19,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":19}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":8,"end":18,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":18}},
|
||||
"left": {
|
||||
"type": "MemberExpression",
|
||||
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 8
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":22,"end":24,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":24}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":29,"end":31,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":31}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
var foo = async ([(foo)]) => {};
|
||||
62
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-binding-pattern/output.json
vendored
Normal file
62
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-binding-pattern/output.json
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:19)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":31,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":31}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":10,"end":31,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":31}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":17,"end":24,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":24}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":19,"end":22,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":22},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 18
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":29,"end":31,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":31}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
async (x = async([(f) = []])) => {};
|
||||
@ -0,0 +1,77 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":28,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":28}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "CallExpression",
|
||||
"start":11,"end":28,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":28}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":11,"end":16,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":16},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ArrayExpression",
|
||||
"start":17,"end":27,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":27}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":18,"end":26,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":26}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"f"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 18
|
||||
},
|
||||
"name": "f"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":24,"end":26,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":26}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":33,"end":35,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":35}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-array/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-array/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var foo = async ([...(foo)]) => {};
|
||||
66
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-array/output.json
vendored
Normal file
66
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-array/output.json
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:22)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":34,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":34}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":10,"end":34,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":34}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":17,"end":27,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":27}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":18,"end":26,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":26}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":25},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 21
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":32,"end":34,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":34}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-object/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-object/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var foo = async ({...(foo)}) => {};
|
||||
66
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-object/output.json
vendored
Normal file
66
packages/babel-parser/test/fixtures/es2017/async-arrow/parenthesized-rest-object/output.json
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:22)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":34,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":34}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":10,"end":34,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":34}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "ObjectPattern",
|
||||
"start":17,"end":27,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":27}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":18,"end":26,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":26}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":25},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 21
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":32,"end":34,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":34}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
async ([(a.b) = [] ] = []);
|
||||
@ -0,0 +1,72 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":7,"end":25,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":25}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":7,"end":20,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":20}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":8,"end":18,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":18}},
|
||||
"left": {
|
||||
"type": "MemberExpression",
|
||||
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 8
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":23,"end":25,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":25}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
async ([(a) = [] ] = []);
|
||||
@ -0,0 +1,62 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":7,"end":23,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":23}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":7,"end":18,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":18}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":8,"end":16,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":16}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 8
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":21,"end":23,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":23}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-argument-array/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-argument-array/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var foo = async ([(foo)]);
|
||||
55
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-argument-array/output.json
vendored
Normal file
55
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-argument-array/output.json
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":25,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":25}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "CallExpression",
|
||||
"start":10,"end":25,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":25}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ArrayExpression",
|
||||
"start":17,"end":24,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":24}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":19,"end":22,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":22},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 18
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
var foo = async ((foo));
|
||||
@ -0,0 +1,49 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":23,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":23}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "CallExpression",
|
||||
"start":10,"end":23,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":23}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":18,"end":21,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":21},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 17
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-call-expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-call-expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
async ([(a.b) = []] = []);
|
||||
72
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-call-expression/output.json
vendored
Normal file
72
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-call-expression/output.json
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":7,"end":24,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":24}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "ArrayPattern",
|
||||
"start":7,"end":19,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":19}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":8,"end":18,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":18}},
|
||||
"left": {
|
||||
"type": "MemberExpression",
|
||||
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 8
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":22,"end":24,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":24}},
|
||||
"elements": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-array/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-array/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var foo = async ([...(foo)]);
|
||||
59
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-array/output.json
vendored
Normal file
59
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-array/output.json
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":28,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":28}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "CallExpression",
|
||||
"start":10,"end":28,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":28}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ArrayExpression",
|
||||
"start":17,"end":27,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":27}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "SpreadElement",
|
||||
"start":18,"end":26,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":26}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":25},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 21
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-object/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-object/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var foo = async ({...(foo)});
|
||||
59
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-object/output.json
vendored
Normal file
59
packages/babel-parser/test/fixtures/es2017/async-call/parenthesized-spread-object/output.json
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":28,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":28}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "CallExpression",
|
||||
"start":10,"end":28,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":28}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ObjectExpression",
|
||||
"start":17,"end":27,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":27}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "SpreadElement",
|
||||
"start":18,"end":26,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":26}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":25},"identifierName":"foo"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 21
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:24)"
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:1)"
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:2)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":2,"end":3,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":3},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 1
|
||||
},
|
||||
"name": "a"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "NumericLiteral",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:1)"
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid parenthesized assignment pattern (1:2)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":2,"end":3,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":3},"identifierName":"a"},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 1
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":5,"end":9,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":9}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":8,"end":9,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":9},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "NumericLiteral",
|
||||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
((a)) => 42
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:1)"
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
(a, (b)) => 42
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user