Details
-
Bug
-
Resolution: Fixed
-
P3
-
8
-
None
-
b82
Description
{code}
try {
throw new TypeError('error');
} catch (iox) {
function f() {
print(iox.message);
}
}
{code}
breaks
Should throw reference error, according to Chapter 13 of the spec - function with out assignment to identifier is bound to lexical closure, not variable closure. One line fix is:
change
{code}
final List<Block> lookupBlocks = findLookupBlocksHelper(getCurrentFunctionNode(), symbol.findFunction());
for (final Block lookupBlock : lookupBlocks) {
final Symbol refSymbol = lookupBlock.findSymbol(name);
refSymbol.setIsScope();
}
{code}
{code}
final List<Block> lookupBlocks = findLookupBlocksHelper(getCurrentFunctionNode(), symbol.findFunction());
for (final Block lookupBlock : lookupBlocks) {
final Symbol refSymbol = lookupBlock.findSymbol(name);
if (refSymbol != null) { // See NASHORN-837, function declaration in lexical scope: try {} catch (x){ function f() { use(x) } } f()
refSymbol.setIsScope();
}
}
{code}
try {
throw new TypeError('error');
} catch (iox) {
function f() {
print(iox.message);
}
}
{code}
breaks
Should throw reference error, according to Chapter 13 of the spec - function with out assignment to identifier is bound to lexical closure, not variable closure. One line fix is:
change
{code}
final List<Block> lookupBlocks = findLookupBlocksHelper(getCurrentFunctionNode(), symbol.findFunction());
for (final Block lookupBlock : lookupBlocks) {
final Symbol refSymbol = lookupBlock.findSymbol(name);
refSymbol.setIsScope();
}
{code}
{code}
final List<Block> lookupBlocks = findLookupBlocksHelper(getCurrentFunctionNode(), symbol.findFunction());
for (final Block lookupBlock : lookupBlocks) {
final Symbol refSymbol = lookupBlock.findSymbol(name);
if (refSymbol != null) { // See NASHORN-837, function declaration in lexical scope: try {} catch (x){ function f() { use(x) } } f()
refSymbol.setIsScope();
}
}
{code}