| 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: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 dynamic #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 dynamic #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 dynamic #t3 = a1 = #1#0{core::int} in true) || #1#0 is core::int && (let final dynamic #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 dynamic #t5 = a2#case#0 = #0#0{core::int} in true) || #0#0 is core::String && (let final dynamic #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 dynamic #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 dynamic #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 dynamic #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 dynamic #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 dynamic #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; |
| } |
| } |
| } |
| } =>#t11; |
| } |
| static method test6(dynamic x6) → dynamic { |
| return block { |
| final core::Set<core::int> #t13 = col::LinkedHashSet::•<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 dynamic #t14 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final dynamic #t15 = i6 = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #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 dynamic #t17 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) is core::int && (let final dynamic #t18 = n6 = (#0#7#isSet ?{dynamic} #0#7{dynamic} : let final dynamic #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 dynamic #t22 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final dynamic #t23 = i7 = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #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 dynamic #t25 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) is core::int && (let final dynamic #t26 = n7 = (#0#7#isSet ?{dynamic} #0#7{dynamic} : let final dynamic #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 |
| } |