analyzer: update dot shorthand diagnostic to mention static scope#62954
analyzer: update dot shorthand diagnostic to mention static scope#62954console-log-life wants to merge 2 commits intodart-lang:mainfrom
Conversation
…e types Updated the diagnostic message for dot shorthand in messages.yaml. The previous message "no context type" was misleading when the context type was 'dynamic', 'void', or a Record type. The new message correctly identifies that these types lack a static scope. Updated the documentation and common fixes accordingly. Fixes dart-lang#62863
…e types Updated the diagnostic message for dot shorthand in messages.yaml. The previous message "no context type" was misleading when the context type was 'dynamic', 'void', or a Record type. The new message correctly identifies that these types lack a static scope. Updated the documentation and common fixes accordingly. Fixes dart-lang#62863
|
Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at: https://dart-review.googlesource.com/c/sdk/+/489900 Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly. Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR). |
|
CL has new comments, please view and respond to them in Gerrit. If a reviewer requested changes, push new commits to this PR and it will be automatically copied to Gerrit. After that you can mark reviewer comments as resolved in Gerrit and request another round of reviews. Note: when you add comments in Gerrit they only become visible after you send them by clicking Reply and Send. |
|
Please see the feedback on the Gerrit CL at https://dart-review.googlesource.com/c/sdk/+/489900. |
Summary
This PR improves the diagnostic message for dot shorthand expressions in the analyzer. The goal is to address the misleading "no context type" message as discussed in #62863.
The Problem
Previously, when a dot shorthand was used with types like
dynamic,void, or certainRecordtypes, the analyzer reported:As pointed out by the team, this is inaccurate. A context type (like
dynamic) does exist, but it is a type that lacks a static scope, which is required for the dot shorthand to resolve members.Changes Made
pkg/analyzer/messages.yaml: Changed theproblemMessagefordotShorthandMissingContextto accurately reflect the "static scope" requirement.Verification
This change correctly covers the edge cases where a context type is present but lacks static scope:
fd(.hash)where context isdynamic.fv(.hash)where context isvoid.fr(.hash)where context is aRecord.Fixes #62863