src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java

Print this page

        

*** 701,730 **** FunctionNode.Kind.SCRIPT, functionLine, Collections.<IdentNode>emptyList()); lc.push(script); final ParserContextBlockNode body = newBlock(); - // If ES6 block scope is enabled add a per-script block for top-level LET and CONST declarations. - final int startLine = start; - final ParserContextBlockNode outer = useBlockScope() ? newBlock() : null; - functionDeclarations = new ArrayList<>(); ! try { sourceElements(allowPropertyFunction); addFunctionDeclarations(script); - } finally { - if (outer != null) { - restoreBlock(outer); - appendStatement(new BlockStatement( - startLine, - new Block( - functionToken, - startLine, outer.getFlags(), - outer.getStatements()))); - } - } functionDeclarations = null; restoreBlock(body); body.setFlag(Block.NEEDS_SCOPE); final Block programBody = new Block(functionToken, functionLine, body.getFlags(), body.getStatements()); lc.pop(script); script.setLastToken(token); --- 701,716 ---- FunctionNode.Kind.SCRIPT, functionLine, Collections.<IdentNode>emptyList()); lc.push(script); final ParserContextBlockNode body = newBlock(); ! functionDeclarations = new ArrayList<>(); sourceElements(allowPropertyFunction); addFunctionDeclarations(script); functionDeclarations = null; + restoreBlock(body); body.setFlag(Block.NEEDS_SCOPE); final Block programBody = new Block(functionToken, functionLine, body.getFlags(), body.getStatements()); lc.pop(script); script.setLastToken(token);