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

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

Issue 2086063002: Reland: change most cases of variable redeclaration from TypeError to SyntaxError. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « src/runtime/runtime-scopes.cc ('k') | test/mjsunit/regress/redeclaration-error-types.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Var-let conflict in a function throws, even if the var is in an eval 5 // Var-let conflict in a function throws, even if the var is in an eval
6 6
7 // Throws at the top level of a function 7 // Throws at the top level of a function
8 assertThrows(function() { 8 assertThrows(function() {
9 let x = 1; 9 let x = 1;
10 eval('var x'); 10 eval('var x');
11 }, TypeError); 11 }, SyntaxError);
12 12
13 // If the eval is in its own block scope, throws 13 // If the eval is in its own block scope, throws
14 assertThrows(function() { 14 assertThrows(function() {
15 let y = 1; 15 let y = 1;
16 { eval('var y'); } 16 { eval('var y'); }
17 }, TypeError); 17 }, SyntaxError);
18 18
19 // If the let is in its own block scope, with the eval, throws 19 // If the let is in its own block scope, with the eval, throws
20 assertThrows(function() { 20 assertThrows(function() {
21 { 21 {
22 let x = 1; 22 let x = 1;
23 eval('var x'); 23 eval('var x');
24 } 24 }
25 }, TypeError); 25 }, SyntaxError);
26 26
27 // Legal if the let is no longer visible 27 // Legal if the let is no longer visible
28 assertDoesNotThrow(function() { 28 assertDoesNotThrow(function() {
29 { 29 {
30 let x = 1; 30 let x = 1;
31 } 31 }
32 eval('var x'); 32 eval('var x');
33 }); 33 });
34 34
35 // All the same works for const: 35 // All the same works for const:
36 // Throws at the top level of a function 36 // Throws at the top level of a function
37 assertThrows(function() { 37 assertThrows(function() {
38 const x = 1; 38 const x = 1;
39 eval('var x'); 39 eval('var x');
40 }, TypeError); 40 }, SyntaxError);
41 41
42 // If the eval is in its own block scope, throws 42 // If the eval is in its own block scope, throws
43 assertThrows(function() { 43 assertThrows(function() {
44 const y = 1; 44 const y = 1;
45 { eval('var y'); } 45 { eval('var y'); }
46 }, TypeError); 46 }, SyntaxError);
47 47
48 // If the const is in its own block scope, with the eval, throws 48 // If the const is in its own block scope, with the eval, throws
49 assertThrows(function() { 49 assertThrows(function() {
50 { 50 {
51 const x = 1; 51 const x = 1;
52 eval('var x'); 52 eval('var x');
53 } 53 }
54 }, TypeError); 54 }, SyntaxError);
55 55
56 // Legal if the const is no longer visible 56 // Legal if the const is no longer visible
57 assertDoesNotThrow(function() { 57 assertDoesNotThrow(function() {
58 { 58 {
59 const x = 1; 59 const x = 1;
60 } 60 }
61 eval('var x'); 61 eval('var x');
62 }); 62 });
63 63
64 // In global scope 64 // In global scope
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 { 132 {
133 let x = 1; 133 let x = 1;
134 eval('{ function x() {} }'); 134 eval('{ function x() {} }');
135 } 135 }
136 })(); 136 })();
137 } catch (e) { 137 } catch (e) {
138 caught = true; 138 caught = true;
139 } 139 }
140 // TODO(littledan): switch to assertTrue when bug is fixed 140 // TODO(littledan): switch to assertTrue when bug is fixed
141 assertTrue(caught); 141 assertTrue(caught);
OLDNEW
« no previous file with comments | « src/runtime/runtime-scopes.cc ('k') | test/mjsunit/regress/redeclaration-error-types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698