Files
sdk/tests/language/initializing_formal/final_test.dart
T
Robert Nystrom 7134a451f3 Format tests/language/i*.
A lot of files in this one, but nothing interesting in any of the tests.

Change-Id: I69c705bfd2c2b2f9711b393e4ac78c357336e1a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407660
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-02-05 08:36:21 -08:00

21 lines
604 B
Dart

// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class A {
var x, y;
// This should cause an error because `x` is final when accessed as an
// initializing formal.
A(this.x)
: y = (() {
x = 3;
// [error column 9, length 1]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_LOCAL
// [cfe] Can't assign to the final variable 'x'.
});
}
main() {}