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

Unified Diff: src/parser.cc

Issue 1385913003: Fix legacy const for-of/in destructuring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | test/mjsunit/harmony/destructuring.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index f122d9aa5e4b57ff1459cfa48e060c666bd407ff..c241375535bf1a9f40e79433fa477feefbf21272 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2593,7 +2593,9 @@ void Parser::ParseVariableDeclarations(VariableDeclarationContext var_context,
}
// Make sure that 'const x' and 'let x' initialize 'x' to undefined.
- if (value == NULL && parsing_result->descriptor.needs_init) {
+ // If in a for-of/in loop, no need to initialize here.
+ if (value == NULL && parsing_result->descriptor.needs_init &&
+ !is_for_iteration_variable) {
value = GetLiteralUndefined(position());
}
« no previous file with comments | « no previous file | test/mjsunit/harmony/destructuring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698