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 // Flags: --legacy-const 6 7 (function f(){ 8 assertEquals("function", typeof f); 9 })(); 10 11 (function f(){ 12 var f; // Variable shadows function name. 13 assertEquals("undefined", typeof f); 14 })(); 15 16 (function f(){ 17 var f; 18 assertEquals("undefined", typeof f); 19 with ({}); // Force context allocation of both variable and function name. 20 })(); 21 22 assertEquals("undefined", typeof f); 23 24 // var initialization is intercepted by with scope. 25 (function() { 26 var o = { a: 1 }; 27 with (o) { 28 var a = 2; 29 } 30 assertEquals("undefined", typeof a); 31 assertEquals(2, o.a); 32 })(); 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 })(); 43