[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>
This commit is contained in:
Parker Lougheed 2023-12-01 17:32:48 +00:00 committed by Commit Queue
parent ad138aa645
commit b8b67c066c
3 changed files with 4 additions and 4 deletions

View file

@ -12369,7 +12369,8 @@ const Code<Null> codePrivateNamedParameter = messagePrivateNamedParameter;
const MessageCode messagePrivateNamedParameter = const MessageCode(
"PrivateNamedParameter",
analyzerCodes: <String>["PRIVATE_OPTIONAL_PARAMETER"],
problemMessage: r"""An optional named parameter can't start with '_'.""");
problemMessage:
r"""A named parameter can't start with an underscore ('_').""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeRecordFieldsCantBePrivate =

View file

@ -1995,7 +1995,7 @@ FunctionTypeDefaultValue:
analyzerCode: DEFAULT_VALUE_IN_FUNCTION_TYPE
PrivateNamedParameter:
problemMessage: "An optional named parameter can't start with '_'."
problemMessage: "A named parameter can't start with an underscore ('_')."
analyzerCode: PRIVATE_OPTIONAL_PARAMETER
NoFormals:

View file

@ -11,8 +11,7 @@ class Foo {
Foo.private({this._y = 77}) {}
// ^^
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_OPTIONAL_PARAMETER
// ^
// [cfe] An optional named parameter can't start with '_'.
// [cfe] A named parameter can't start with an underscore ('_').
}
main() {