rhino1.7.6.testsrc.jstests.401561.jstest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This function should never work (no x in lexical scope)
function getX() { return x; }
global = this;
(function() {
var x = 12345;
(function() {
// indirect call, not direct-call-optimized,
// uses this scope's parent instead of getX's parent
try {
global["getX"]();
} catch (e) {
if (!(e instanceof ReferenceError))
throw("Expected ReferenceError from getX(), got " + e);
return;
}
throw("Indirect call of getX() did not throw");
})();
})();
// call site triggers direct-call optimization of getX;
// remove this line and the bug doesn't manifest!
function neverCalled() { getX(); }
"success"
© 2015 - 2024 Weber Informatics LLC | Privacy Policy