c4724e5a89
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>
53 lines
2.2 KiB
Plaintext
53 lines
2.2 KiB
Plaintext
library;
|
|
//
|
|
// Problems in library:
|
|
//
|
|
// pkg/front_end/testcases/patterns/error_cases.dart:6:9: Error: Expected ';' after this.
|
|
// final Square(:areaAsInt) || Square(:areaAsInt) = Square(2);
|
|
// ^^^^^^
|
|
//
|
|
// pkg/front_end/testcases/patterns/error_cases.dart:6:16: Error: Expected an identifier, but got ':'.
|
|
// Try inserting an identifier before ':'.
|
|
// final Square(:areaAsInt) || Square(:areaAsInt) = Square(2);
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/patterns/error_cases.dart:6:17: Error: Undefined name 'areaAsInt'.
|
|
// final Square(:areaAsInt) || Square(:areaAsInt) = Square(2);
|
|
// ^^^^^^^^^
|
|
//
|
|
// pkg/front_end/testcases/patterns/error_cases.dart:6:38: Error: Expected an identifier, but got ':'.
|
|
// Try inserting an identifier before ':'.
|
|
// final Square(:areaAsInt) || Square(:areaAsInt) = Square(2);
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/patterns/error_cases.dart:6:39: Error: Undefined name 'areaAsInt'.
|
|
// final Square(:areaAsInt) || Square(:areaAsInt) = Square(2);
|
|
// ^^^^^^^^^
|
|
//
|
|
// pkg/front_end/testcases/patterns/error_cases.dart:6:50: Error: Can't assign to this.
|
|
// final Square(:areaAsInt) || Square(:areaAsInt) = Square(2);
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/patterns/error_cases.dart:8:10: Error: Refutable patterns can't be used in an irrefutable context.
|
|
// Try using an if-case, a 'switch' statement, or a 'switch' expression instead.
|
|
// final (42) = 42;
|
|
// ^
|
|
//
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
static method method() → dynamic {
|
|
final dynamic Square;
|
|
invalid-expression "pkg/front_end/testcases/patterns/error_cases.dart:6:50: Error: Can't assign to this.
|
|
final Square(:areaAsInt) || Square(:areaAsInt) = Square(2);
|
|
^";
|
|
{
|
|
final synthesized core::int #0#0 = 42;
|
|
if(!invalid-expression "pkg/front_end/testcases/patterns/error_cases.dart:8:10: Error: Refutable patterns can't be used in an irrefutable context.
|
|
Try using an if-case, a 'switch' statement, or a 'switch' expression instead.
|
|
final (42) = 42;
|
|
^")
|
|
throw{for-error-handling} new core::StateError::•("Pattern matching error");
|
|
}
|
|
}
|