mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:19:49 +00:00
[dart2wasm] Check bounds in list []
and []=
These tests now pass: - co19/Language/Expressions/Lists/indices_t01 - co19/LibTest/collection/UnmodifiableListView/operator_subscript_A02_t01 - co19/LibTest/core/List/List_A01_t01 - corelib/iterable_element_at_test/none - corelib/list_growable_test - corelib/list_unmodifiable_test - corelib/range_error_test - language/no_such_method/empty_selector_test - language/unsorted/range_analysis2_test - language/unsorted/value_range2_test - language/unsorted/value_range3_test - language/unsorted/value_range_test Change-Id: Ia96ebf6490e01e647c482406639accbfe40d44fc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264700 Commit-Queue: Ömer Ağacan <omersa@google.com> Reviewed-by: Joshua Litt <joshualitt@google.com>
This commit is contained in:
parent
1a7df42224
commit
7e87efd2e7
|
@ -18,6 +18,7 @@ abstract class _ListBase<E> extends ListBase<E> {
|
||||||
_ListBase._withData(this._length, this._data);
|
_ListBase._withData(this._length, this._data);
|
||||||
|
|
||||||
E operator [](int index) {
|
E operator [](int index) {
|
||||||
|
RangeError.checkValidIndex(index, this, "[]", _length);
|
||||||
return unsafeCast(_data.read(index));
|
return unsafeCast(_data.read(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ abstract class _ModifiableList<E> extends _ListBase<E> {
|
||||||
: super._withData(length, data);
|
: super._withData(length, data);
|
||||||
|
|
||||||
void operator []=(int index, E value) {
|
void operator []=(int index, E value) {
|
||||||
|
RangeError.checkValidIndex(index, this, "[]=", _length);
|
||||||
_data.write(index, value);
|
_data.write(index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue