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

Unified Diff: sdk/lib/core/errors.dart

Issue 1180713003: Better messages for optimized index errors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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: sdk/lib/core/errors.dart
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart
index 144921a474ac8b98367eb32d50e9c6856c1c63c4..0e99b0b271ce48375f613c2fc9522aad6d0e5019 100644
--- a/sdk/lib/core/errors.dart
+++ b/sdk/lib/core/errors.dart
@@ -282,7 +282,8 @@ class RangeError extends ArgumentError {
static void checkValidIndex(int index, var indexable,
[String name, int length, String message]) {
if (length == null) length = indexable.length;
- if (index < 0 || index >= length) {
+ // Comparing with `0` as receiver produces better dart2js type inference.
+ if (0 > index || index >= length) {
if (name == null) name = "index";
throw new RangeError.index(index, indexable, name, message, length);
}

Powered by Google App Engine
This is Rietveld 408576698