Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: src/parsing/parser-base.h

Issue 2679263002: Revert of [parsing] Fix maybe-assigned for loop variables. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index e1e3d3412281a274f2a3d03079735cc7c113a2de..9375bb0df5bb2f04a65e3dd336829e9c573029be 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -1346,24 +1346,6 @@
bool IsValidPattern(ExpressionT expression) {
return expression->IsObjectLiteral() || expression->IsArrayLiteral();
}
-
- // Due to hoisting, the value of a 'var'-declared variable may actually change
- // even if the code contains only the "initial" assignment, namely when that
- // assignment occurs inside a loop. For example:
- //
- // let i = 10;
- // do { var x = i } while (i--):
- //
- // As a simple and very conservative approximation of this, we explicitly mark
- // as maybe-assigned any non-lexical variable whose initializing "declaration"
- // does not syntactically occur in the function scope. (In the example above,
- // it occurs in a block scope.)
- //
- // Note that non-lexical variables include temporaries, which may also get
- // assigned inside a loop due to the various rewritings that the parser
- // performs.
- //
- static void MarkLoopVariableAsAssigned(Scope* scope, Variable* var);
// Keep track of eval() calls since they disable all local variable
// optimizations. This checks if expression is an eval call, and if yes,
@@ -5716,12 +5698,8 @@
return loop;
}
-template <typename Impl>
-void ParserBase<Impl>::MarkLoopVariableAsAssigned(Scope* scope, Variable* var) {
- if (!IsLexicalVariableMode(var->mode()) && !scope->is_function_scope()) {
- var->set_maybe_assigned();
- }
-}
+#undef CHECK_OK
+#undef CHECK_OK_CUSTOM
template <typename Impl>
void ParserBase<Impl>::ObjectLiteralChecker::CheckDuplicateProto(
@@ -5773,8 +5751,6 @@
}
}
-#undef CHECK_OK
-#undef CHECK_OK_CUSTOM
#undef CHECK_OK_VOID
} // namespace internal
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698