Files
sdk/tests/language/parameter/initializer6_test.dart
T
Parker Lougheed b8b67c066c [cfe] Correct PrivateNamedParameter problem message
Named parameters can't start with underscores whether they are optional or required.

Change-Id: Iaaeab80f74a691b4981148f06412a60ca115f73e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337883
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-12-01 17:32:48 +00:00

20 lines
580 B
Dart

// Copyright (c) 2019, 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";
/// It is a compile-time error if a named formal parameter begins with an '_'.
class Foo {
num _y;
Foo.private({this._y = 77}) {}
// ^^
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_OPTIONAL_PARAMETER
// [cfe] A named parameter can't start with an underscore ('_').
}
main() {
Foo.private(_y: 222);
}