Closed
Description
Part of #49749.
This is the reason for the runtime error on co19/LanguageFeatures/Patterns/logical_and_A03_t02
test.
Example:
main() {
var x = [1, 2];
if (x case [1]) {
print('Bug!');
} else {
print('OK');
}
}
Kernel:
static method main() → dynamic {
core::List<core::int> x = core::_GrowableList::_literal2<core::int>(1, 2);
final core::List<core::int> #t1 = x;
final core::bool #t2 = true;
final core::List<core::int> #t3 = #t1;
if(#t3.{core::List::length}{core::int}.{core::num::>=}(1){(core::num) → core::bool}) {
final dynamic #t4 = #t3{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic};
if(#t4 =={core::Object::==}{(core::Object) → core::bool} 1) {
#t2 = false;
{
core::print("Bug!");
}
}
}
if(#t2) {
core::print("OK");
}
}
Note that the list pattern incorrectly checks if x.length >= 1
and not x.length == 1
.