Files
sdk/pkg/front_end/testcases/patterns/variable_names.dart.strong.expect
T
Johnni Winther c4724e5a89 [cfe] Add Throw.forErrorHandling
This adds a `forErrorHandling` to the `Throw` node. This is used that the `throw` is *not* present in the source code but added to ensure
correctness and/or soundness of the generated code.

This is used for instance in the lowering for handling duplicate writes
to a late final field or for pattern assignments that don't match.

In response to https://github.com/dart-lang/sdk/issues/53519

TEST=updated ast-to-text

Change-Id: Ie103829d98fda9cd7b64e9e3d893e77d1e86d7d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347900
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2024-02-19 12:12:02 +00:00

106 lines
6.7 KiB
Plaintext

library;
//
// Problems in library:
//
// pkg/front_end/testcases/patterns/variable_names.dart:24:23: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
// } else if (x case A(: [1, 2])) { // Error
// ^
//
// pkg/front_end/testcases/patterns/variable_names.dart:26:22: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
// } else if (x case (: [1, 2])) { // Error
// ^
//
import self as self;
import "dart:core" as core;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract get foo() → core::int?;
abstract get bar() → core::int;
abstract get baz() → core::int?;
abstract get boz() → core::num;
abstract get qux() → core::bool;
abstract get quux() → core::String;
abstract get foobar() → core::int;
}
static method test(dynamic x, dynamic y, dynamic z) → dynamic {
dynamic qux;
dynamic quux;
{
final synthesized dynamic #0#0 = x;
synthesized core::int? #0#2;
synthesized core::bool #0#2#isSet = false;
synthesized core::int? #0#5;
synthesized core::bool #0#5#isSet = false;
synthesized core::num #0#7;
synthesized core::bool #0#7#isSet = false;
{
hoisted core::int foo;
hoisted core::int bar;
hoisted core::int baz;
hoisted core::double boz;
hoisted core::int foobar;
if(#0#0 is self::A && (let final dynamic #t1 = (#0#2#isSet ?{core::int?} #0#2{core::int?} : let final dynamic #t2 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::foo}{core::int?})! in let final dynamic #t3 = foo = (#0#2#isSet ?{core::int?} #0#2{core::int?} : let final dynamic #t4 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::foo}{core::int?})! in true) && (let final dynamic #t5 = bar = #0#0{self::A}.{self::A::bar}{core::int} in true) && !((#0#5#isSet ?{core::int?} #0#5{core::int?} : let final dynamic #t6 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::baz}{core::int?}) == null)) {
baz = (#0#5#isSet ?{core::int?} #0#5{core::int?} : let final dynamic #t7 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::baz}{core::int?}) as{Unchecked} core::int;
(#0#7#isSet ?{core::num} #0#7{core::num} : let final dynamic #t8 = #0#7#isSet = true in #0#7 = #0#0{self::A}.{self::A::boz}{core::num}) as core::double;
boz = (#0#7#isSet ?{core::num} #0#7{core::num} : let final dynamic #t9 = #0#7#isSet = true in #0#7 = #0#0{self::A}.{self::A::boz}{core::num}) as core::double;
foobar = #0#0{self::A}.{self::A::foobar}{core::int};
{
return 0;
}
}
else {
final synthesized dynamic #1#0 = x;
synthesized core::Object? #1#2;
synthesized core::bool #1#2#isSet = false;
synthesized core::Object? #1#5;
synthesized core::bool #1#5#isSet = false;
synthesized core::Object? #1#7;
synthesized core::bool #1#7#isSet = false;
{
hoisted dynamic foo;
hoisted dynamic bar;
hoisted dynamic baz;
hoisted core::double boz;
hoisted dynamic foobar;
if(#1#0 is (core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?}) && (let final dynamic #t10 = (#1#2#isSet ?{core::Object?} #1#2{core::Object?} : let final dynamic #t11 = #1#2#isSet = true in #1#2 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.foo{core::Object?})! in let final dynamic #t12 = foo = (#1#2#isSet ?{core::Object?} #1#2{core::Object?} : let final dynamic #t13 = #1#2#isSet = true in #1#2 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.foo{core::Object?})! in true) && (let final dynamic #t14 = bar = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.bar{core::Object?} in true) && !((#1#5#isSet ?{core::Object?} #1#5{core::Object?} : let final dynamic #t15 = #1#5#isSet = true in #1#5 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.baz{core::Object?}) == null)) {
baz = #1#5#isSet ?{core::Object?} #1#5{core::Object?} : let final dynamic #t16 = #1#5#isSet = true in #1#5 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.baz{core::Object?};
(#1#7#isSet ?{core::Object?} #1#7{core::Object?} : let final dynamic #t17 = #1#7#isSet = true in #1#7 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.$1{core::Object?}) as core::double;
boz = (#1#7#isSet ?{core::Object?} #1#7{core::Object?} : let final dynamic #t18 = #1#7#isSet = true in #1#7 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.$1{core::Object?}) as core::double;
foobar = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.foobar{core::Object?};
{
return 1;
}
}
else {
final synthesized dynamic #2#0 = x;
if(#2#0 is self::A) {
return 2;
}
else {
final synthesized dynamic #3#0 = x;
if(#3#0 is (core::Object?) && invalid-expression "pkg/front_end/testcases/patterns/variable_names.dart:26:22: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
} else if (x case (: [1, 2])) { // Error
^") {
return 3;
}
}
}
}
}
}
}
{
final synthesized dynamic #4#0 = y as{TypeError,ForDynamic} self::A;
if(!(#4#0 is self::A && (let final dynamic #t19 = qux = #4#0{self::A}.{self::A::qux}{core::bool} in true) && (let final dynamic #t20 = quux = #4#0{self::A}.{self::A::quux}{core::String} in true)))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
{
final synthesized dynamic #5#0 = z as{TypeError,ForDynamic} (dynamic, {quux: dynamic});
if(!(#5#0 is (core::Object?, {quux: core::Object?}) && (let final dynamic #t21 = qux = #5#0{(core::Object?, {quux: core::Object?})}.$1{core::Object?} in true) && (let final dynamic #t22 = quux = #5#0{(core::Object?, {quux: core::Object?})}.quux{core::Object?} in true)))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
}