734c01da41
This reports an error on assignment to primary constructor parameters in field initializers and initializer lists. The change includes a rewrite of the handle of variable lookup and use that fixes and existing problem in pattern assignment, where it was until now possible to assign to const and final variable in some cases. Part of #61700 Change-Id: Icfe566fd03b805e8fc21c4b373dbb8ab3dab4b7a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484141 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
21 lines
624 B
Plaintext
21 lines
624 B
Plaintext
library;
|
|
//
|
|
// Problems in library:
|
|
//
|
|
// pkg/front_end/testcases/patterns/pattern_variable_final.dart:8:4: Error: Can't assign to the final variable 'i'.
|
|
// (i, _) = r;
|
|
// ^
|
|
//
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
static method method((core::int, core::int) r, final core::int i) → dynamic {
|
|
{
|
|
final synthesized(core::int, core::int) #0#0 = r;
|
|
if(!invalid-expression "pkg/front_end/testcases/patterns/pattern_variable_final.dart:8:4: Error: Can't assign to the final variable 'i'.
|
|
(i, _) = r;
|
|
^")
|
|
throw{for-error-handling} new core::StateError::•("Pattern matching error");
|
|
}
|
|
}
|