| library; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/patterns/issue51112.dart:8:47: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern. |
| // Try assigning to a different variable. |
| // case [int y, _] when () { setToOne = () { y = 1; }; return true; }(): |
| // ^ |
| // |
| // pkg/front_end/testcases/patterns/issue51112.dart:9:47: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern. |
| // Try assigning to a different variable. |
| // case [_, int y] when () { setToOne = () { y = 1; }; return true; }(): |
| // ^ |
| // |
| // pkg/front_end/testcases/patterns/issue51112.dart:12:47: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern. |
| // Try assigning to a different variable. |
| // case [double y] when () { setToOne = () { y = 1.0; }; return true; }(): |
| // ^ |
| // |
| import self as self; |
| import "dart:core" as core; |
| |
| static method test(dynamic x) → dynamic { |
| () → void setToOne = () → void {}; |
| #L1: |
| { |
| final synthesized dynamic #0#0 = x; |
| synthesized core::bool #0#4; |
| synthesized core::bool #0#4#isSet = false; |
| synthesized core::int #0#2; |
| synthesized core::bool #0#2#isSet = false; |
| synthesized dynamic #0#6; |
| synthesized core::bool #0#6#isSet = false; |
| synthesized dynamic #0#7; |
| synthesized core::bool #0#7#isSet = false; |
| dynamic #t1; |
| { |
| lowered hoisted core::int y#case#0; |
| lowered hoisted core::int y#case#1; |
| if(#0#0 is core::List<dynamic> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t2 = #0#4#isSet = true in #0#4 = (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t3 = #0#2#isSet = true in #0#2 = #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 #t4 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final dynamic #t5 = y#case#0 = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t6 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int in true)) && (() → core::bool { |
| setToOne = () → void { |
| y#case#0 = 1; |
| }; |
| return true; |
| })(){() → core::bool} && (let final dynamic #t7 = #t1 = y#case#0 in true) || #0#0 is core::List<dynamic> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t8 = #0#4#isSet = true in #0#4 = (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t9 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C1) && ((#0#7#isSet ?{dynamic} #0#7{dynamic} : let final dynamic #t10 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) is core::int && (let final dynamic #t11 = y#case#1 = (#0#7#isSet ?{dynamic} #0#7{dynamic} : let final dynamic #t12 = #0#7#isSet = true in #0#7 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic}) as{Unchecked} core::int in true)) && (() → core::bool { |
| setToOne = () → void { |
| y#case#1 = 1; |
| }; |
| return true; |
| })(){() → core::bool} && (let final dynamic #t13 = #t1 = y#case#1 in true)) { |
| core::int y = #t1{core::int}; |
| { |
| setToOne(){() → void}; |
| return y; |
| } |
| } |
| } |
| { |
| hoisted core::double y; |
| if(#0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t14 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C2 && ((#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t15 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::double && (let final dynamic #t16 = y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t17 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::double in true)) && (() → core::bool { |
| setToOne = () → void { |
| y = 1.0; |
| }; |
| return true; |
| })(){() → core::bool}) { |
| { |
| setToOne(){() → void}; |
| return y; |
| } |
| } |
| } |
| { |
| { |
| { |
| return null; |
| } |
| } |
| } |
| } |
| } |
| static method main() → dynamic { |
| self::expectEquals(self::test(<core::Object>[0, "foo"]), 0); |
| self::expectEquals(self::test(<core::Object>["foo", 0]), 0); |
| self::expectEquals(self::test(<core::double>[3.14]), 1.0); |
| self::expectEquals(self::test(null), null); |
| } |
| static method expectEquals(dynamic x, dynamic y) → dynamic { |
| if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) { |
| throw "Expected ${x} to be equal to ${y}."; |
| } |
| } |
| |
| constants { |
| #C1 = 2 |
| #C2 = 1 |
| } |