v8/test/mjsunit/regress/regress-599068-func-bindings.js
mythria 8982cb5c70 [Interpreter] Handles legacy constants in strict mode.
Function bindings are the only variables in LEGACY_CONST mode.
(https://codereview.chromium.org/1819123002/). Since these variables
can also be accessed in strict mode functions we should support
handling such variables. Assigning to a legacy constant throws
a TypeError in strict mode. Also fixes hydrogen.cc to throw a
TypeError for legacy constants.

BUG=v8:4280,chromium:599068
LOG=N
TBR=rmcilroy@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35383}
2016-04-11 12:04:01 +00:00

46 lines
1.1 KiB
JavaScript

// Copyright 2016 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: --allow-natives-syntax
// Tests function bindings are correctly handled in ignition.
(function f() {
function assignSloppy() {
f = 0;
}
assertDoesNotThrow(assignSloppy);
function assignStrict() {
'use strict';
f = 0;
}
assertThrows(assignStrict, TypeError);
function assignStrictLookup() {
eval("'use strict'; f = 1;");
}
assertThrows(assignStrictLookup, TypeError);
})();
// Tests for compound assignments which are handled differently
// in crankshaft.
(function f() {
function assignSloppy() {
f += "x";
}
assertDoesNotThrow(assignSloppy);
assertDoesNotThrow(assignSloppy);
%OptimizeFunctionOnNextCall(assignSloppy);
assertDoesNotThrow(assignSloppy);
function assignStrict() {
'use strict';
f += "x";
}
assertThrows(assignStrict, TypeError);
assertThrows(assignStrict, TypeError);
%OptimizeFunctionOnNextCall(assignStrict);
assertThrows(assignStrict, TypeError);
})();