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

Misleading error message for Invalid constant value error #49389

Closed
sarbagyastha opened this issue Jul 4, 2022 · 2 comments
Closed

Misleading error message for Invalid constant value error #49389

sarbagyastha opened this issue Jul 4, 2022 · 2 comments
Labels
analyzer-constants area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sarbagyastha
Copy link

Getting A value of type 'Null' can't be assigned to a parameter of type 'Map<String, String>' in a const constructor. as in the screenshot of DartPad below.

image

@lrhn lrhn added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Jul 4, 2022
@johnniwinther johnniwinther added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. and removed area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Jul 4, 2022
@johnniwinther
Copy link
Member

The A value of type ... message comes from the analyzer.

copybara-service bot pushed a commit that referenced this issue Jul 25, 2023
…onstant value.

evaluateConstructorCall now returns a Constant, which means evaluation may be cut early in some places if there's an error. However, some code generators rely on _InstanceCreationEvaluator to complete, and so there's no _major_ changes to the design right now (and some small additions to avoid breaking many tests).

This CL is just the framework for the "return Constant" design and will be the base for reporting better errors in constructor invocations.

These changes already show that we cut some amount of over-reporting in our existing language and unit tests, which is a step in the right direction.

Bug: #47603, #47351, #49389

Change-Id: I5ba7f1282658884c18a32d5e98c7804bbfeac0f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312347
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
@kallentu
Copy link
Member

Fixed after ba00516.

copybara-service bot pushed a commit that referenced this issue Jul 26, 2023
… be assigned to a parameter' overreporting in the const evaluator.

The constant evaluator now handles invalid types better and won't overreport this nonsensical error.

Bug: #47603, #47351, #49389
Change-Id: I63c253d2177c2b8c259c364e83753653eac1cae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312707
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-constants area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants