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