Skip to content

Fixes #62864 Improve error message in the analyzer#62924

Open
Darkildo wants to merge 1 commit intodart-lang:mainfrom
Darkildo:Improve-error-message-in-the-analyzer-in-case-of-void-in-a-spread
Open

Fixes #62864 Improve error message in the analyzer#62924
Darkildo wants to merge 1 commit intodart-lang:mainfrom
Darkildo:Improve-error-message-in-the-analyzer-in-case-of-void-in-a-spread

Conversation

@Darkildo
Copy link
Copy Markdown
Contributor

Fix analyzer diagnostics for spread expressions with void type.

What this PR changes

  • Adds an early useOfVoidResult check in spread verification for list/set and map literals.
  • Prevents uncheckedUseOfNullableValueInSpread from being reported for non-null-aware spreads when the spread expression has type void.
  • Adds regression tests for list/set/map spreads (including null-aware spreads) to ensure only useOfVoidResult is reported.

Why

Using a void expression in a spread should report useOfVoidResult and stop further spread validation. This avoids cascading or misleading diagnostics in this invalid scenario.

@copybara-service
Copy link
Copy Markdown

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/+/488528

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).

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

1 similar comment
@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has been approved, please wait for a reviewer to merge it.

There are also new comments on the CL, please review them and respond if necessary because reviewer might have requested clarifications or possibly some final changes and will not merge the CL until their questions have been answered.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has been approved, please wait for a reviewer to merge it.

There are also new comments on the CL, please review them and respond if necessary because reviewer might have requested clarifications or possibly some final changes and will not merge the CL until their questions have been answered.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has been approved, please wait for a reviewer to merge it.

There are also new comments on the CL, please review them and respond if necessary because reviewer might have requested clarifications or possibly some final changes and will not merge the CL until their questions have been answered.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has been approved, please wait for a reviewer to merge it.

There are also new comments on the CL, please review them and respond if necessary because reviewer might have requested clarifications or possibly some final changes and will not merge the CL until their questions have been answered.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has been approved, please wait for a reviewer to merge it.

There are also new comments on the CL, please review them and respond if necessary because reviewer might have requested clarifications or possibly some final changes and will not merge the CL until their questions have been answered.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has been approved, please wait for a reviewer to merge it.

There are also new comments on the CL, please review them and respond if necessary because reviewer might have requested clarifications or possibly some final changes and will not merge the CL until their questions have been answered.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures as well as new comments, please review them in Gerrit.

You will need to address both the comments and the failures before requesting another review.

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.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures as well as new comments, please review them in Gerrit.

You will need to address both the comments and the failures before requesting another review.

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.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures as well as new comments, please review them in Gerrit.

You will need to address both the comments and the failures before requesting another review.

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.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures as well as new comments, please review them in Gerrit.

You will need to address both the comments and the failures before requesting another review.

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.

spread fix

simplify test

Update use_of_void_result_test.dart

replace tests by error type

replace check inside function block

Reorder tests and remove unreachable errors

remove remaining extra params in test

replace tests

Update not_map_spread_test.dart

resolver revert to base fixed version
@Darkildo Darkildo force-pushed the Improve-error-message-in-the-analyzer-in-case-of-void-in-a-spread branch from 2d9f015 to 83e5c20 Compare March 26, 2026 15:25
@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

1 similar comment
@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/488528 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures as well as new comments, please review them in Gerrit.

You will need to address both the comments and the failures before requesting another review.

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.

@copybara-service
Copy link
Copy Markdown

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.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures as well as new comments, please review them in Gerrit.

You will need to address both the comments and the failures before requesting another review.

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.

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures as well as new comments, please review them in Gerrit.

You will need to address both the comments and the failures before requesting another review.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant