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

Unified Diff: sdk/lib/_internal/compiler/js_lib/js_array.dart

Issue 1187553005: Revert "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 7283f21f667f81e6943acb950095d8aa851e1d08..d706b7512780c72e7bc400f4396d384557c79c05 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_array.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_array.dart
@@ -575,28 +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.value(newLength, 'newLength');
- }
- // TODO(sra): Remove this test and let JavaScript throw an error.
- if (newLength < 0) {
- throw new RangeError.range(newLength, 0, null, 'newLength');
- }
- // JavaScript with throw a RangeError for numbers that are too big. The
- // message does not contain the value.
+ if (newLength is !int) throw new ArgumentError(newLength);
+ if (newLength < 0) throw new RangeError.value(newLength);
JS('void', r'#.length = #', this, newLength);
}
E operator [](int index) {
- if (index is !int) throw diagnoseIndexError(this, index);
- if (index >= length || index < 0) throw diagnoseIndexError(this, index);
+ if (index is !int) throw new ArgumentError(index);
+ if (index >= length || index < 0) throw new RangeError.value(index);
return JS('var', '#[#]', this, index);
}
void operator []=(int index, E value) {
checkMutable('indexed set');
- if (index is !int) throw diagnoseIndexError(this, index);
- if (index >= length || index < 0) throw diagnoseIndexError(this, index);
+ if (index is !int) throw new ArgumentError(index);
+ if (index >= length || index < 0) throw new RangeError.value(index);
JS('void', r'#[#] = #', this, index, value);
}
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/interceptors.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698