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

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: Update with Johnni'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..0e357afa7bcc693f00c3c52e6ee0db1a0c1f2718 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -747,10 +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)));
- return closeFunction();
+ // 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.toString() == variable.name) {
Siggi Cherem (dart-lang) 2016/11/02 18:17:20 toString is mainly something we use for debugging
Emily Fortuna 2016/11/02 18:24:58 Done.
+ sourceInfoNode = definition.assignmentOperator;
Siggi Cherem (dart-lang) 2016/11/02 18:17:20 let's add a break here as well (it doesn't change
Emily Fortuna 2016/11/02 18:24:58 Done.
+ }
+ }
+
+ closeAndGotoExit(new HReturn(value, sourceInformationBuilder.buildReturn(
+ sourceInfoNode)));
+ return closeFunction(); // token or source
Siggi Cherem (dart-lang) 2016/11/02 18:17:20 remove trailing comment?
Emily Fortuna 2016/11/02 18:24:58 whoops thanks.
}
/**
« 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