[ast] AstTraversalVisitor should visit the Declarations of Block scopes

R=marja@chromium.org

Bug: v8:6509
Change-Id: If8be12e2ce6c00de0bdee38ab721ef5b7b47efe5
Reviewed-on: https://chromium-review.googlesource.com/556239
Reviewed-by: Marja Hölttä <marja@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46331}
This commit is contained in:
Adam Klein 2017-06-29 10:19:41 -07:00 committed by Commit Bot
parent 8516076a6c
commit 4c79544cca
2 changed files with 27 additions and 0 deletions

View File

@ -136,6 +136,9 @@ void AstTraversalVisitor<Subclass>::VisitFunctionDeclaration(
template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitBlock(Block* stmt) {
PROCESS_NODE(stmt);
if (stmt->scope() != nullptr) {
RECURSE_EXPRESSION(VisitDeclarations(stmt->scope()->declarations()));
}
RECURSE(VisitStatements(stmt->statements()));
}

View File

@ -0,0 +1,24 @@
// Copyright 2017 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 testSloppy() {
var arrow = (sth = (function f() {
{
function f2() { }
}
})()) => 0;
assertEquals(0, arrow());
})();
(function testStrict() {
"use strict";
var arrow = (sth = (function f() {
{
function f2() { }
}
})()) => 0;
assertEquals(0, arrow());
})();