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

Unified Diff: sdk/lib/_internal/compiler/js_lib/js_array.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/_internal/compiler/js_lib/js_array.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/js_array.dart b/sdk/lib/_internal/compiler/js_lib/js_array.dart
index d706b7512780c72e7bc400f4396d384557c79c05..e30e1068d0e913d00fe47107591c880e304e7d3b 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_array.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_array.dart
@@ -575,21 +575,21 @@ class JSArray<E> extends Interceptor implements List<E>, JSIndexable {
void set length(int newLength) {
checkGrowable('set length');
- if (newLength is !int) throw new ArgumentError(newLength);
+ if (newLength is !int) throw new ArgumentError.value(newLength);
Lasse Reichstein Nielsen 2015/06/12 14:24:36 consider passing "newLength" as second argument.
sra1 2015/06/12 22:29:04 Done.
if (newLength < 0) throw new RangeError.value(newLength);
Lasse Reichstein Nielsen 2015/06/12 14:24:36 Consider using new RangeError.range(newLength, 0,
sra1 2015/06/12 22:29:05 I have done this for now. The error feels wordy a
JS('void', r'#.length = #', this, newLength);
}
E operator [](int index) {
- if (index is !int) throw new ArgumentError(index);
- if (index >= length || index < 0) throw new RangeError.value(index);
+ if (index is !int) throw diagnoseIndexError(this, index);
+ if (index >= length || index < 0) throw diagnoseIndexError(this, index);
return JS('var', '#[#]', this, index);
}
void operator []=(int index, E value) {
checkMutable('indexed set');
- if (index is !int) throw new ArgumentError(index);
- if (index >= length || index < 0) throw new RangeError.value(index);
+ if (index is !int) throw diagnoseIndexError(this, index);
+ if (index >= length || index < 0) throw diagnoseIndexError(this, index);
JS('void', r'#[#] = #', this, index, value);
}

Powered by Google App Engine
This is Rietveld 408576698