Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: test/mjsunit/es6/block-eval-var-over-legacy-const.js

Issue 1819123002: Remove support for legacy const, part 1 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased, deleted one more file Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/declare-locally.js ('k') | test/mjsunit/es6/block-let-contextual-sloppy.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-sloppy --harmony-sloppy-let --harmony-sloppy-function
6 // Flags: --legacy-const
7
8 // Legacy-const-let conflict in a function throws, even if the legacy const
9 // is in an eval
10
11 // Throws at the top level of a function
12 assertThrows(function() {
13 let x = 1;
14 eval('const x = 2');
15 }, TypeError);
16
17 // If the eval is in its own block scope, throws
18 assertThrows(function() {
19 let y = 1;
20 { eval('const y = 2'); }
21 }, TypeError);
22
23 // If the let is in its own block scope, with the eval, throws
24 assertThrows(function() {
25 {
26 let x = 1;
27 eval('const x = 2');
28 }
29 }, TypeError);
30
31 // Legal if the let is no longer visible
32 assertDoesNotThrow(function() {
33 {
34 let x = 1;
35 }
36 eval('const x = 2');
37 });
38
39 // In global scope
40 let caught = false;
41 try {
42 let z = 1;
43 eval('const z = 2');
44 } catch (e) {
45 caught = true;
46 }
47 assertTrue(caught);
48
49 // Let declarations beyond a function boundary don't conflict
50 caught = false;
51 try {
52 let a = 1;
53 (function() {
54 eval('const a');
55 })();
56 } catch (e) {
57 caught = true;
58 }
59 assertFalse(caught);
60
61 // legacy const across with doesn't conflict
62 caught = false;
63 try {
64 (function() {
65 with ({x: 1}) {
66 eval("const x = 2;");
67 }
68 })();
69 } catch (e) {
70 caught = true;
71 }
72 assertFalse(caught);
73
74 // legacy const can still conflict with let across a with
75 caught = false;
76 try {
77 (function() {
78 let x;
79 with ({x: 1}) {
80 eval("const x = 2;");
81 }
82 })();
83 } catch (e) {
84 caught = true;
85 }
86 assertTrue(caught);
OLDNEW
« no previous file with comments | « test/mjsunit/declare-locally.js ('k') | test/mjsunit/es6/block-let-contextual-sloppy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698