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

Unified Diff: frog/leg/operations.dart

Issue 9866027: Error out on compile-time constants if equality is tested on bad types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
Index: frog/leg/operations.dart
diff --git a/frog/leg/operations.dart b/frog/leg/operations.dart
index 0f5ea51f6da5595c823b0b0c52191e0a2d913875..f9a7cd528dbbccef49a04a1e60afd8075d5d9f28 100644
--- a/frog/leg/operations.dart
+++ b/frog/leg/operations.dart
@@ -241,8 +241,12 @@ class EqualsOperation implements BinaryOperation {
NumConstant leftNum = left;
NumConstant rightNum = right;
return new BoolConstant(leftNum.value == rightNum.value);
+ } else if (!left.isConstructedObject()) {
Lasse Reichstein Nielsen 2012/03/27 08:12:12 I'd prefer else if (left.isConstructedObject())
floitsch 2012/03/28 00:25:21 hehe. that's what I had before. After long hesitat
+ // Unless we know that the user-defined object does not implement the
+ // equality operator we cannot fold here.
+ return new BoolConstant(left == right);
}
- return new BoolConstant(left == right);
+ return null;
}
}

Powered by Google App Engine
This is Rietveld 408576698