| Index: src/preparser.h
|
| diff --git a/src/preparser.h b/src/preparser.h
|
| index dd36de789090d35e8724e71fce2b4f7605acd5a8..36b0b4a201a6ed12d0adae5dcd37ad21dde16609 100644
|
| --- a/src/preparser.h
|
| +++ b/src/preparser.h
|
| @@ -555,7 +555,7 @@ class ParserBase : public Traits {
|
| ExpressionT expr, bool* ok) {
|
| if (classifier->is_valid_binding_pattern()) {
|
| // A simple arrow formal parameter: IDENTIFIER => BODY.
|
| - if (!this->IsIdentifier(expr)) {
|
| + if (!allow_harmony_destructuring() && !this->IsIdentifier(expr)) {
|
| Traits::ReportMessageAt(scanner()->location(),
|
| MessageTemplate::kUnexpectedToken,
|
| Token::String(scanner()->current_token()));
|
| @@ -1555,7 +1555,7 @@ class PreParserTraits {
|
| return !tag.IsNoTemplateTag();
|
| }
|
|
|
| - void DeclareFormalParameter(Scope* scope, PreParserIdentifier param,
|
| + void DeclareFormalParameter(Scope* scope, PreParserExpression pattern,
|
| ExpressionClassifier* classifier, bool is_rest) {}
|
|
|
| void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {}
|
| @@ -3487,10 +3487,21 @@ void ParserBase<Traits>::ParseFormalParameter(Scope* scope, bool is_rest,
|
| bool* ok) {
|
| // FormalParameter[Yield,GeneratorParameter] :
|
| // BindingElement[?Yield, ?GeneratorParameter]
|
| - IdentifierT name = ParseAndClassifyIdentifier(classifier, ok);
|
| +
|
| + Token::Value next = peek();
|
| + ExpressionT pattern = ParsePrimaryExpression(classifier, ok);
|
| + if (!*ok) return;
|
| +
|
| + ValidateBindingPattern(classifier, ok);
|
| if (!*ok) return;
|
|
|
| - Traits::DeclareFormalParameter(scope, name, classifier, is_rest);
|
| + if (!allow_harmony_destructuring() && !Traits::IsIdentifier(pattern)) {
|
| + ReportUnexpectedToken(next);
|
| + *ok = false;
|
| + return;
|
| + }
|
| +
|
| + Traits::DeclareFormalParameter(scope, pattern, classifier, is_rest);
|
| }
|
|
|
|
|
|
|