blob: 6659e5311b6d9607a14123a6a4e84cfbda1bc114 [file] [log] [blame]
library;
//
// Problems in library:
//
// pkg/front_end/testcases/patterns/issue51971_2.dart:6:27: Error: Read of a non-const variable is not a constant expression.
// if (x1 case int a1 && < a1 || int a1) { // Error.
// ^
//
// pkg/front_end/testcases/patterns/issue51971_2.dart:8:44: Error: Read of a non-const variable is not a constant expression.
// } else if (x1 case int a1 || int a1 && < a1) { // Error.
// ^
//
// pkg/front_end/testcases/patterns/issue51971_2.dart:27:22: Error: Read of a non-const variable is not a constant expression.
// case int a3 && < a3: // Error.
// ^
//
// pkg/front_end/testcases/patterns/issue51971_2.dart:28:26: Error: Read of a non-const variable is not a constant expression.
// case String a3 && == a3: // Error.
// ^
//
// pkg/front_end/testcases/patterns/issue51971_2.dart:37:22: Error: Read of a non-const variable is not a constant expression.
// case int a4 && < a4 when a4 > 0: // Error.
// ^
//
// pkg/front_end/testcases/patterns/issue51971_2.dart:38:26: Error: Read of a non-const variable is not a constant expression.
// case String a4 && == a4 when a4.startsWith("f"): // Error.
// ^
//
// pkg/front_end/testcases/patterns/issue51971_2.dart:47:17: Error: Read of a non-const variable is not a constant expression.
// int a5 && < a5 => 1, // Error.
// ^
//
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
import "dart:collection" as col;
static method test1(dynamic x1) dynamic {
{
final synthesized dynamic #0#0 = x1;
final const synthesized core::int #0#1 = invalid-expression "Read of a non-const variable is not a constant expression.";
{
hoisted core::int a1;
if(#0#0 is core::int && (let final core::int #t1 = a1 = #0#0{core::int} in true) && #0#0{core::int}.{core::num::<}(invalid-expression "Read of a non-const variable is not a constant expression."){(core::num) → core::bool} || #0#0 is core::int && (let final core::int #t2 = a1 = #0#0{core::int} in true)) {
return a1;
}
else {
final synthesized dynamic #1#0 = x1;
final const synthesized core::int #1#1 = invalid-expression "Read of a non-const variable is not a constant expression.";
{
hoisted core::int a1;
if(#1#0 is core::int && (let final core::int #t3 = a1 = #1#0{core::int} in true) || #1#0 is core::int && (let final core::int #t4 = a1 = #1#0{core::int} in true) && #1#0{core::int}.{core::num::<}(invalid-expression "Read of a non-const variable is not a constant expression."){(core::num) → core::bool}) {
return a1;
}
else {
return null;
}
}
}
}
}
}
static method test2(dynamic x2) dynamic {
#L1:
{
final synthesized dynamic #0#0 = x2;
{
lowered hoisted core::int a2#case#0;
lowered hoisted core::String a2#case#1;
if(#0#0 is core::int && (let final core::int #t5 = a2#case#0 = #0#0{core::int} in true) || #0#0 is core::String && (let final core::String #t6 = a2#case#1 = #0#0{core::String} in true)) {
{
return 1;
}
}
}
{
{
{
return 0;
}
}
}
}
}
static method test3(dynamic x3) dynamic {
#L2:
{
final synthesized dynamic #0#0 = x3;
final const synthesized core::int #0#1 = invalid-expression "Read of a non-const variable is not a constant expression.";
final const synthesized core::String #0#3 = invalid-expression "Read of a non-const variable is not a constant expression.";
{
lowered hoisted core::int a3#case#0;
lowered hoisted core::String a3#case#1;
if(#0#0 is core::int && (let final core::int #t7 = a3#case#0 = #0#0{core::int} in true) && #0#0{core::int}.{core::num::<}(invalid-expression "Read of a non-const variable is not a constant expression."){(core::num) → core::bool} || #0#0 is core::String && (let final core::String #t8 = a3#case#1 = #0#0{core::String} in true) && #0#0{core::String} =={core::String::==}{(core::Object) → core::bool} invalid-expression "Read of a non-const variable is not a constant expression.") {
{
return 1;
}
}
}
{
{
{
return 0;
}
}
}
}
}
static method test4(dynamic x4) dynamic {
#L3:
{
final synthesized dynamic #0#0 = x4;
final const synthesized core::int #0#1 = invalid-expression "Read of a non-const variable is not a constant expression.";
final const synthesized core::String #0#3 = invalid-expression "Read of a non-const variable is not a constant expression.";
{
lowered hoisted core::int a4#case#0;
lowered hoisted core::String a4#case#1;
if(#0#0 is core::int && (let final core::int #t9 = a4#case#0 = #0#0{core::int} in true) && #0#0{core::int}.{core::num::<}(invalid-expression "Read of a non-const variable is not a constant expression."){(core::num) → core::bool} && a4#case#0.{core::num::>}(0){(core::num) → core::bool} || #0#0 is core::String && (let final core::String #t10 = a4#case#1 = #0#0{core::String} in true) && #0#0{core::String} =={core::String::==}{(core::Object) → core::bool} invalid-expression "Read of a non-const variable is not a constant expression." && a4#case#1.{core::String::startsWith}("f"){(core::Pattern, [core::int]) → core::bool}) {
{
return 1;
}
}
}
{
{
{
return 0;
}
}
}
}
}
static method test5(dynamic x5) dynamic {
return block {
core::int #t11;
final synthesized dynamic #0#0 = x5;
final const synthesized core::int #0#1 = invalid-expression "Read of a non-const variable is not a constant expression.";
#L4:
{
{
hoisted core::int a5;
if(#0#0 is core::int && (let final core::int #t12 = a5 = #0#0{core::int} in true) && #0#0{core::int}.{core::num::<}(invalid-expression "Read of a non-const variable is not a constant expression."){(core::num) → core::bool}) {
#t11 = 1;
break #L4;
}
}
{
if(true) {
#t11 = 0;
break #L4;
}
}
throw{for-error-handling} new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t11;
}
static method test6(dynamic x6) dynamic {
return block {
final core::Set<core::int> #t13 = new col::_Set::•<core::int>();
hoisted core::int i6;
hoisted core::int n6;
{
final synthesized dynamic #0#0 = x6 as{TypeError,ForDynamic} core::List<core::int>;
synthesized dynamic #0#6;
synthesized core::bool #0#6#isSet = false;
synthesized dynamic #0#7;
synthesized core::bool #0#7#isSet = false;
if(!(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && ((#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t14 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final core::int #t15 = i6 = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t16 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int in true)) && ((#0#7#isSet ?{dynamic} #0#7{dynamic} : let final core::bool #t17 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) is core::int && (let final core::int #t18 = n6 = (#0#7#isSet ?{dynamic} #0#7{dynamic} : let final core::bool #t19 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) as{Unchecked} core::int in true))))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
final core::int #t20 = i6;
final core::int #t21 = n6;
for (core::int i6 = #t20, core::int n6 = #t21; i6.{core::num::<}(n6){(core::num) → core::bool}; i6 = i6.{core::num::+}(1){(core::num) → core::int})
#t13.{core::Set::add}{Invariant}(i6){(core::int) → core::bool};
} =>#t13;
}
static method test7(dynamic x7) dynamic {
{
hoisted core::int i7;
hoisted core::int n7;
{
final synthesized dynamic #0#0 = x7 as{TypeError,ForDynamic} core::List<core::int>;
synthesized dynamic #0#6;
synthesized core::bool #0#6#isSet = false;
synthesized dynamic #0#7;
synthesized core::bool #0#7#isSet = false;
if(!(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && ((#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t22 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final core::int #t23 = i7 = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t24 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int in true)) && ((#0#7#isSet ?{dynamic} #0#7{dynamic} : let final core::bool #t25 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) is core::int && (let final core::int #t26 = n7 = (#0#7#isSet ?{dynamic} #0#7{dynamic} : let final core::bool #t27 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) as{Unchecked} core::int in true))))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
final core::int #t28 = i7;
final core::int #t29 = n7;
for (core::int i7 = #t28, core::int n7 = #t29; i7.{core::num::<}(n7){(core::num) → core::bool}; i7 = i7.{core::num::+}(1){(core::num) → core::int}) {
if(i7.{core::num::%}(3){(core::num) core::int} =={core::num::==}{(core::Object) core::bool} 0)
return i7;
}
}
return null;
}
constants {
#C1 = 2
}