Open
Description
Similarly to #48132, List.insertAll
can leave null
elements in a list with a non-nullable element type if the operation is interrupted by an exception:
import 'dart:collection';
class BadList extends ListBase<int> {
int get length => 2;
int operator [](int index) => throw "BOOM";
set length(int l) => throw "unimplemented";
void operator []=(int index, int value) => throw "unimplemented";
void add(int e) => throw "unimplemented";
}
main() {
List<int> list = [1, 2];
try {
list.insertAll(1, BadList());
} catch (_) {}
print(list.length);
print(list[2]);
}
This prints either
4
null
or
4
undefined
depending on optimization level.