Skip to content

Commit

Permalink
[cfe] Correct PrivateNamedParameter problem message
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
parlough authored and Commit Queue committed Dec 1, 2023
1 parent ad138aa commit b8b67c0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion pkg/front_end/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions tests/language/parameter/initializer6_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit b8b67c0

Please # to comment.