68c7523e63
If it's shadowed by a variable of the same name and both are forcibly context-allocated, the function is assigned to the wrong context slot. R=rossberg@chromium.org BUG=v8:3138 LOG=Y Review URL: https://codereview.chromium.org/159903008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19379 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
41 lines
892 B
JavaScript
41 lines
892 B
JavaScript
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
(function f(){
|
|
assertEquals("function", typeof f);
|
|
})();
|
|
|
|
(function f(){
|
|
var f; // Variable shadows function name.
|
|
assertEquals("undefined", typeof f);
|
|
})();
|
|
|
|
(function f(){
|
|
var f;
|
|
assertEquals("undefined", typeof f);
|
|
with ({}); // Force context allocation of both variable and function name.
|
|
})();
|
|
|
|
assertEquals("undefined", typeof f);
|
|
|
|
// var initialization is intercepted by with scope.
|
|
(function() {
|
|
var o = { a: 1 };
|
|
with (o) {
|
|
var a = 2;
|
|
}
|
|
assertEquals("undefined", typeof a);
|
|
assertEquals(2, o.a);
|
|
})();
|
|
|
|
// const initialization is not intercepted by with scope.
|
|
(function() {
|
|
var o = { a: 1 };
|
|
with (o) {
|
|
const a = 2;
|
|
}
|
|
assertEquals(2, a);
|
|
assertEquals(1, o.a);
|
|
})();
|