diff --git a/src/compiler/ast-loop-assignment-analyzer.cc b/src/compiler/ast-loop-assignment-analyzer.cc index 334c5978a86..97da140b81c 100644 --- a/src/compiler/ast-loop-assignment-analyzer.cc +++ b/src/compiler/ast-loop-assignment-analyzer.cc @@ -254,10 +254,12 @@ void ALAA::VisitForStatement(ForStatement* loop) { void ALAA::VisitForInStatement(ForInStatement* loop) { + Expression* l = loop->each(); Enter(loop); - Visit(loop->each()); + Visit(l); Visit(loop->subject()); Visit(loop->body()); + if (l->IsVariableProxy()) AnalyzeAssignment(l->AsVariableProxy()->var()); Exit(loop); } diff --git a/test/mjsunit/regress/regress-crbug-647887.js b/test/mjsunit/regress/regress-crbug-647887.js new file mode 100644 index 00000000000..84e598d5aa9 --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-647887.js @@ -0,0 +1,14 @@ +// Copyright 2016 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. + +// Flags: --allow-natives-syntax + +function f(obj) { + var key; + for (key in obj) { } + return key === undefined; +} + +%OptimizeFunctionOnNextCall(f); +assertFalse(f({ foo:0 }));