From 4c79544cca77f927cddb3849b66e4ffa8fcc70fc Mon Sep 17 00:00:00 2001 From: Adam Klein Date: Thu, 29 Jun 2017 10:19:41 -0700 Subject: [PATCH] [ast] AstTraversalVisitor should visit the Declarations of Block scopes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R=marja@chromium.org Bug: v8:6509 Change-Id: If8be12e2ce6c00de0bdee38ab721ef5b7b47efe5 Reviewed-on: https://chromium-review.googlesource.com/556239 Reviewed-by: Marja Hölttä Commit-Queue: Adam Klein Cr-Commit-Position: refs/heads/master@{#46331} --- src/ast/ast-traversal-visitor.h | 3 +++ test/mjsunit/regress/regress-6509.js | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/mjsunit/regress/regress-6509.js diff --git a/src/ast/ast-traversal-visitor.h b/src/ast/ast-traversal-visitor.h index a8bb3eb55e..2fa68e02d3 100644 --- a/src/ast/ast-traversal-visitor.h +++ b/src/ast/ast-traversal-visitor.h @@ -136,6 +136,9 @@ void AstTraversalVisitor::VisitFunctionDeclaration( template void AstTraversalVisitor::VisitBlock(Block* stmt) { PROCESS_NODE(stmt); + if (stmt->scope() != nullptr) { + RECURSE_EXPRESSION(VisitDeclarations(stmt->scope()->declarations())); + } RECURSE(VisitStatements(stmt->statements())); } diff --git a/test/mjsunit/regress/regress-6509.js b/test/mjsunit/regress/regress-6509.js new file mode 100644 index 0000000000..85a7815a61 --- /dev/null +++ b/test/mjsunit/regress/regress-6509.js @@ -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()); +})();