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

Unified Diff: runtime/lib/growable_array.cc

Issue 1318943005: Update range errors to agree on the numbers. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: More tests Created 5 years, 3 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: runtime/lib/growable_array.cc
diff --git a/runtime/lib/growable_array.cc b/runtime/lib/growable_array.cc
index 8181e737229aeb4c153157cda13f063797a1315e..e89281370e0b5810d960827be89c1e1192e89e35 100644
--- a/runtime/lib/growable_array.cc
+++ b/runtime/lib/growable_array.cc
@@ -20,7 +20,7 @@ DEFINE_NATIVE_ENTRY(GrowableList_allocate, 2) {
Exceptions::ThrowRangeError(
"length",
Integer::Handle(Integer::New(data.Length())),
- 1,
+ 0, // This is the limit the user sees.
Array::kMaxElements);
}
const GrowableObjectArray& new_array =
@@ -35,7 +35,7 @@ DEFINE_NATIVE_ENTRY(GrowableList_getIndexed, 2) {
GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1));
if ((index.Value() < 0) || (index.Value() >= array.Length())) {
- Exceptions::ThrowRangeError("index", index, 0, array.Length());
+ Exceptions::ThrowRangeError("index", index, 0, array.Length() - 1);
}
const Instance& obj = Instance::CheckedHandle(array.At(index.Value()));
return obj.raw();
@@ -47,7 +47,7 @@ DEFINE_NATIVE_ENTRY(GrowableList_setIndexed, 3) {
GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1));
if ((index.Value() < 0) || (index.Value() >= array.Length())) {
- Exceptions::ThrowRangeError("index", index, 0, array.Length());
+ Exceptions::ThrowRangeError("index", index, 0, array.Length() - 1);
}
GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(2));
array.SetAt(index.Value(), value);

Powered by Google App Engine
This is Rietveld 408576698