forked from v8/v8
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 [email protected] Review URL: https://codereview.chromium.org/1845223006 Cr-Commit-Position: refs/heads/master@{#35383}
- Loading branch information
1 parent
af1f78b
commit 8982cb5
Showing
3 changed files
with
71 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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); | ||
})(); |