OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 // Flags: --legacy-const | |
6 | |
7 (function f(){ | 5 (function f(){ |
8 assertEquals("function", typeof f); | 6 assertEquals("function", typeof f); |
9 })(); | 7 })(); |
10 | 8 |
11 (function f(){ | 9 (function f(){ |
12 var f; // Variable shadows function name. | 10 var f; // Variable shadows function name. |
13 assertEquals("undefined", typeof f); | 11 assertEquals("undefined", typeof f); |
14 })(); | 12 })(); |
15 | 13 |
16 (function f(){ | 14 (function f(){ |
17 var f; | 15 var f; |
18 assertEquals("undefined", typeof f); | 16 assertEquals("undefined", typeof f); |
19 with ({}); // Force context allocation of both variable and function name. | 17 with ({}); // Force context allocation of both variable and function name. |
20 })(); | 18 })(); |
21 | 19 |
22 assertEquals("undefined", typeof f); | 20 assertEquals("undefined", typeof f); |
23 | 21 |
24 // var initialization is intercepted by with scope. | 22 // var initialization is intercepted by with scope. |
25 (function() { | 23 (function() { |
26 var o = { a: 1 }; | 24 var o = { a: 1 }; |
27 with (o) { | 25 with (o) { |
28 var a = 2; | 26 var a = 2; |
29 } | 27 } |
30 assertEquals("undefined", typeof a); | 28 assertEquals("undefined", typeof a); |
31 assertEquals(2, o.a); | 29 assertEquals(2, o.a); |
32 })(); | 30 })(); |
33 | |
34 // const initialization is not intercepted by with scope. | |
35 (function() { | |
36 var o = { a: 1 }; | |
37 with (o) { | |
38 const a = 2; | |
39 } | |
40 assertEquals(2, a); | |
41 assertEquals(1, o.a); | |
42 })(); | |
OLD | NEW |