blob: a666e64f83b930e2974454c6b71d4e592b989d4b [file] [log] [blame]
library;
//
// Problems in library:
//
// pkg/front_end/testcases/patterns/assignment_in_guard.dart:7:22: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern.
// Try assigning to a different variable.
// case var v when (v = 1) > 0:
// ^
//
// pkg/front_end/testcases/patterns/assignment_in_guard.dart:15:37: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern.
// Try assigning to a different variable.
// var z = switch (42) { int v when (v = 1) >= 0 => v, _ => -1 };
// ^
//
// pkg/front_end/testcases/patterns/assignment_in_guard.dart:20:27: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern.
// Try assigning to a different variable.
// if (42 case var v when (v = 1) > 0) {
// ^
//
// pkg/front_end/testcases/patterns/assignment_in_guard.dart:26:40: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern.
// Try assigning to a different variable.
// List l = [1, if (42 case int v when (v = 1) > 0) v else 1, 3];
// ^
//
// pkg/front_end/testcases/patterns/assignment_in_guard.dart:33:17: Error: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern.
// Try assigning to a different variable.
// 5 when (a = 4) < 1 => true,
// ^
//
import self as self;
import "dart:core" as core;
static method test1() void {
#L1:
{
final synthesized core::int #0#0 = 42;
{
hoisted core::int v;
if((let final core::int #t1 = v = #0#0 in true) && (v = 1).{core::num::>}(0){(core::num) → core::bool}) {
{
core::print(v);
break #L1;
}
}
}
{
{}
}
}
}
static method test2() void {
core::int z = block {
core::int #t2;
final synthesized core::int #0#0 = 42;
#L2:
{
{
hoisted core::int v;
if(#0#0 is core::int && (let final core::int #t3 = v = #0#0 in true) && (v = 1).{core::num::>=}(0){(core::num) → core::bool}) {
#t2 = v;
break #L2;
}
}
{
if(true) {
#t2 = 1.{core::int::unary-}(){() → core::int};
break #L2;
}
}
}
} =>#t2;
core::print(z);
}
static method test3() void {
{
final synthesized core::int #0#0 = 42;
{
hoisted core::int v;
if((let final core::int #t4 = v = #0#0 in true) && (v = 1).{core::num::>}(0){(core::num) → core::bool}) {
core::print(v);
}
}
}
}
static method test4() void {
core::List<dynamic> l = block {
final core::List<dynamic> #t5 = core::_GrowableList::_literal1<dynamic>(1);
{
final synthesized core::int #0#0 = 42;
{
hoisted core::int v;
if(#0#0 is core::int && (let final core::int #t6 = v = #0#0 in true) && (v = 1).{core::num::>}(0){(core::num) → core::bool})
#t5.{core::List::add}{Invariant}(v){(dynamic) → void};
else
#t5.{core::List::add}{Invariant}(1){(dynamic) → void};
}
}
#t5.{core::List::add}{Invariant}(3){(dynamic) → void};
} =>#t5;
core::print(l);
}
static method test5(dynamic o) void {
{
final synthesized dynamic #1#0 = o;
{
hoisted dynamic a;
if(#1#0 is core::List<dynamic> && #1#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t7 = a = #1#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true) && ( block {
core::bool #t8;
final synthesized dynamic #0#0 = a;
#L3:
{
{
if(#C2 =={core::num::==}{(core::Object) core::bool} #0#0 && (a = 4).{core::num::<}(1){(core::num) → core::bool}) {
#t8 = true;
break #L3;
}
}
{
if(true) {
#t8 = false;
break #L3;
}
}
}
} =>#t8)) {
core::print(a);
}
}
}
}
constants {
#C1 = 1
#C2 = 5
}
Extra constant evaluation status:
Evaluated: InstanceInvocation @ org-dartlang-testcase:///assignment_in_guard.dart:15:60 -> IntConstant(-1)
Extra constant evaluation: evaluated: 79, effectively constant: 1