Don't throw on assignment to function name binding in harmony sloppy mode

BUG=v8:4482
LOG=n

Review URL: https://codereview.chromium.org/1397513004

Cr-Commit-Position: refs/heads/master@{#31218}
This commit is contained in:
adamk 2015-10-12 09:55:15 -07:00 committed by Commit bot
parent e887d42342
commit 18534dffc9
2 changed files with 12 additions and 6 deletions

View File

@ -4717,12 +4717,9 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
// NOTE: We create a proxy and resolve it here so that in the
// future we can change the AST to only refer to VariableProxies
// instead of Variables and Proxies as is the case now.
Token::Value fvar_init_op = Token::INIT_CONST_LEGACY;
bool use_strict_const = is_strict(scope_->language_mode()) ||
(!allow_legacy_const() && allow_harmony_sloppy());
if (use_strict_const) {
fvar_init_op = Token::INIT_CONST;
}
const bool use_strict_const = is_strict(scope_->language_mode());
Token::Value fvar_init_op =
use_strict_const ? Token::INIT_CONST : Token::INIT_CONST_LEGACY;
VariableMode fvar_mode = use_strict_const ? CONST : CONST_LEGACY;
Variable* fvar = new (zone())
Variable(scope_, function_name, fvar_mode, Variable::NORMAL,

View File

@ -0,0 +1,9 @@
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --harmony-sloppy --nolegacy-const
assertEquals("function", (function f() { f = 42; return typeof f })());
assertEquals("function",
(function* g() { g = 42; yield typeof g })().next().value);