| Index: src/preparser.h
|
| diff --git a/src/preparser.h b/src/preparser.h
|
| index 541da23af1acfb83b59426c34e664195844bb9d5..182b6fb63f87488a3a84fbcc9e02d96021643362 100644
|
| --- a/src/preparser.h
|
| +++ b/src/preparser.h
|
| @@ -352,12 +352,16 @@ class ParserBase : public Traits {
|
| Mode old_mode_;
|
| };
|
|
|
| - Scope* NewScope(Scope* parent, ScopeType scope_type,
|
| - FunctionKind kind = kNormalFunction) {
|
| + Scope* NewScope(Scope* parent, ScopeType scope_type) {
|
| + // Must always pass the function kind for FUNCTION_SCOPE and ARROW_SCOPE.
|
| + DCHECK(scope_type != FUNCTION_SCOPE && scope_type != ARROW_SCOPE);
|
| + return NewScope(parent, scope_type, kNormalFunction);
|
| + }
|
| +
|
| + Scope* NewScope(Scope* parent, ScopeType scope_type, FunctionKind kind) {
|
| DCHECK(ast_value_factory());
|
| DCHECK(scope_type != MODULE_SCOPE || allow_harmony_modules());
|
| - DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) ||
|
| - kind == kNormalFunction);
|
| + DCHECK(scope_type != ARROW_SCOPE || IsArrowFunction(kind));
|
| Scope* result = new (zone())
|
| Scope(zone(), parent, scope_type, ast_value_factory(), kind);
|
| result->Initialize();
|
| @@ -1642,7 +1646,8 @@ class PreParserTraits {
|
| }
|
|
|
| static PreParserExpression SuperReference(Scope* scope,
|
| - PreParserFactory* factory) {
|
| + PreParserFactory* factory,
|
| + int pos) {
|
| return PreParserExpression::Default();
|
| }
|
|
|
| @@ -2282,7 +2287,8 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
|
| Consume(Token::LPAREN);
|
| if (allow_harmony_arrow_functions() && Check(Token::RPAREN)) {
|
| // As a primary expression, the only thing that can follow "()" is "=>".
|
| - Scope* scope = this->NewScope(scope_, ARROW_SCOPE);
|
| + Scope* scope =
|
| + this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction);
|
| scope->set_start_position(beg_pos);
|
| FormalParameterErrorLocations error_locs;
|
| bool has_rest = false;
|
| @@ -2764,7 +2770,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
|
| FormalParameterErrorLocations error_locs;
|
| Scanner::Location loc(lhs_location.beg_pos, scanner()->location().end_pos);
|
| bool has_rest = false;
|
| - Scope* scope = this->NewScope(scope_, ARROW_SCOPE);
|
| + Scope* scope =
|
| + this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction);
|
| scope->set_start_position(lhs_location.beg_pos);
|
| this->ParseArrowFunctionFormalParameters(scope, expression, loc,
|
| &error_locs, &has_rest, CHECK_OK);
|
| @@ -3324,7 +3331,7 @@ ParserBase<Traits>::ParseStrongSuperCallExpression(
|
| Consume(Token::SUPER);
|
| int pos = position();
|
| Scanner::Location super_loc = scanner()->location();
|
| - ExpressionT expr = this->SuperReference(scope_, factory());
|
| + ExpressionT expr = this->SuperReference(scope_, factory(), pos);
|
|
|
| if (peek() != Token::LPAREN) {
|
| ReportMessage("strong_constructor_super");
|
| @@ -3371,21 +3378,23 @@ typename ParserBase<Traits>::ExpressionT
|
| ParserBase<Traits>::ParseSuperExpression(bool is_new,
|
| ExpressionClassifier* classifier,
|
| bool* ok) {
|
| + int pos = position();
|
| Expect(Token::SUPER, CHECK_OK);
|
|
|
| - // TODO(wingo): Does this actually work with lazily compiled arrows?
|
| - FunctionState* function_state = function_state_;
|
| - while (IsArrowFunction(function_state->kind())) {
|
| - function_state = function_state->outer();
|
| + Scope* scope = scope_->DeclarationScope();
|
| +
|
| + while (scope->is_eval_scope() || scope->is_arrow_scope()) {
|
| + scope = scope->outer_scope();
|
| + DCHECK_NOT_NULL(scope);
|
| + scope = scope->DeclarationScope();
|
| }
|
| - // TODO(arv): Handle eval scopes similarly.
|
|
|
| - FunctionKind kind = function_state->kind();
|
| + FunctionKind kind = scope->function_kind();
|
| if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
|
| i::IsConstructor(kind)) {
|
| if (peek() == Token::PERIOD || peek() == Token::LBRACK) {
|
| - scope_->RecordSuperPropertyUsage();
|
| - return this->SuperReference(scope_, factory());
|
| + scope->RecordSuperPropertyUsage();
|
| + return this->SuperReference(scope_, factory(), pos);
|
| }
|
| // new super() is never allowed.
|
| // super() is only allowed in derived constructor
|
| @@ -3396,8 +3405,10 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new,
|
| *ok = false;
|
| return this->EmptyExpression();
|
| }
|
| - function_state->set_super_location(scanner()->location());
|
| - return this->SuperReference(scope_, factory());
|
| + // TODO(rossberg): This might not be the correct FunctionState for the
|
| + // method here.
|
| + function_state_->set_super_location(scanner()->location());
|
| + return this->SuperReference(scope_, factory(), pos);
|
| }
|
| }
|
|
|
|
|