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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 2471543004: Fix compiler crash when we declare several (global) variables, but only define some of them. (Closed)
Patch Set: Siggi's comments Created 4 years, 1 month 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 | tests/compiler/dart2js/constant_expression_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 9e17d7a9a503202de4c087bd2b3aba3d73dcb598..ca2e07ed6802febc100dee7565611eafe8ea00f0 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -747,9 +747,20 @@ class SsaBuilder extends ast.Visitor
visit(initializer);
HInstruction value = pop();
value = potentiallyCheckOrTrustType(value, variable.type);
- ast.SendSet sendSet = node.definitions.nodes.head;
- closeAndGotoExit(new HReturn(value,
- sourceInformationBuilder.buildReturn(sendSet.assignmentOperator)));
+ // In the case of multiple declarations (and some definitions) on the same
+ // line, the source pointer needs to point to the right initialized
+ // variable. So find the specific initialized variable we are referring to.
+ ast.Node sourceInfoNode = initializer;
+ for (var definition in node.definitions) {
+ if (definition is ast.SendSet &&
+ definition.selector.asIdentifier().source == variable.name) {
+ sourceInfoNode = definition.assignmentOperator;
+ break;
+ }
+ }
+
+ closeAndGotoExit(new HReturn(value, sourceInformationBuilder.buildReturn(
+ sourceInfoNode)));
return closeFunction();
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698