Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify error message for const (ASSIGNMENT_TO_CONST) #56953

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/error/codes.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
/// No parameters.
static const CompileTimeErrorCode ASSIGNMENT_TO_CONST = CompileTimeErrorCode(
'ASSIGNMENT_TO_CONST',
"Constant variables can't be assigned a value.",
"Constant variables can't be assigned a value after initialization.",
correctionMessage:
"Try removing the assignment, or remove the modifier 'const' from the "
"variable.",
Expand Down
5 changes: 3 additions & 2 deletions pkg/analyzer/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# Run
#
# dart run analyzer/tool/messages/generate.dart
# dart run analyzer/tool/diagnostics/generate.dart
#
# to regenerate messages after having edited this file.

#
# This file is organized as a two level map, where the outer key corresponds to
# the name of an analyzer error class (e.g. CompileTimeErrorCode), and the inner
# key corresponds to the name of a static variable in that class, describing a
Expand Down Expand Up @@ -788,7 +789,7 @@ CompileTimeErrorCode:
}
```
ASSIGNMENT_TO_CONST:
problemMessage: "Constant variables can't be assigned a value."
problemMessage: "Constant variables can't be assigned a value after initialization."
correctionMessage: "Try removing the assignment, or remove the modifier 'const' from the variable."
hasPublishedDocs: true
comment: No parameters.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
convert: ^3.0.0
crypto: ^3.0.0
glob: ^2.0.0
macros: '>=0.1.3-main.0 <0.1.4'
macros: ^0.0.1
meta: ^1.15.0
package_config: ^2.0.0
path: ^1.9.0
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/tool/diagnostics/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ function producing the value.

### assignment_to_const

_Constant variables can't be assigned a value._
_Constant variables can't be assigned a value after initialization._

#### Description

Expand Down