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

Unified Diff: sdk/lib/_internal/compiler/js_lib/js_string.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_string.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/js_string.dart b/sdk/lib/_internal/compiler/js_lib/js_string.dart
index 43f938024dd675592a0c8d7098320acc7447f371..e381b1f24c100b3f78ba40b5fd5bfce762692d91 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_string.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_string.dart
@@ -14,9 +14,9 @@ class JSString extends Interceptor implements String, JSIndexable {
const JSString();
int codeUnitAt(int index) {
- if (index is !int) throw new ArgumentError(index);
- if (index < 0) throw new RangeError.value(index);
- if (index >= length) throw new RangeError.value(index);
+ if (index is !int) throw diagnoseIndexError(this, index);
+ if (index < 0) throw diagnoseIndexError(this, index);
+ if (index >= length) throw diagnoseIndexError(this, index);
return JS('JSUInt31', r'#.charCodeAt(#)', this, index);
}
@@ -44,7 +44,7 @@ class JSString extends Interceptor implements String, JSIndexable {
}
String operator +(String other) {
- if (other is !String) throw new ArgumentError(other);
+ if (other is !String) throw new ArgumentError.value(other);
return JS('String', r'# + #', this, other);
}
@@ -469,8 +469,8 @@ class JSString extends Interceptor implements String, JSIndexable {
int get length => JS('int', r'#.length', this);
String 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('String', '#[#]', this, index);
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_helper.dart ('k') | sdk/lib/_internal/compiler/js_lib/native_typed_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698