cfe9932a9e
This is the first step in adjusting the runtime error raised on a pattern mismatch in an irrefutable context. For now, the error message isn't specialized and doesn't reflect the nature of the mismatch. Part of https://github.com/dart-lang/sdk/issues/51720 Part of https://github.com/dart-lang/sdk/issues/49749 Change-Id: Ie4b997a1a36e92b25f1372f4dd98941dbcc08b61 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290842 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
53 lines
2.2 KiB
Plaintext
53 lines
2.2 KiB
Plaintext
library /*isNonNullableByDefault*/;
|
|
//
|
|
// 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 dynamic #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 new core::StateError::•("Pattern matching error");
|
|
}
|
|
}
|