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

enable strict-casts #125

Open
goderbauer opened this issue May 25, 2023 · 4 comments
Open

enable strict-casts #125

goderbauer opened this issue May 25, 2023 · 4 comments

Comments

@goderbauer
Copy link
Contributor

Helps in catching unintended runtime errors related to dynamic.

See also #44, which is the other part of this puzzle.

@github-project-automation github-project-automation bot moved this to Triage backlog in Lints Triage Jun 1, 2023
@devoncarew devoncarew changed the title Consider enabeling strict-casts in core or recommended Consider enabling strict-casts in core or recommended Jun 1, 2023
@lrhn
Copy link
Member

lrhn commented Jun 7, 2023

The "strict-casts" flag is not a lint, just an analyzer flag (https://dart.dev/guides/language/analysis-options#enabling-additional-type-checks).

It makes it an error to have an implicit downcast from dynamic. That's one of the affordances of dynamic, but if someone wants to disable it, they're free to do so.

I don't think it's something we should enabled by default in the recommended lints, not unless we would also be willing to work towards removing it from the language entirely. I don't think we're there today.

@devoncarew devoncarew moved this from Triage backlog to Under consideration in Lints Triage Sep 5, 2023
@devoncarew
Copy link
Member

devoncarew commented Sep 19, 2023

We need more investigation to take action here, and will likely evaluate strict-inference and strict-raw-types as well.

@github-project-automation github-project-automation bot moved this to Triage backlog in Lints Triage Sep 19, 2023
@devoncarew devoncarew moved this from Triage backlog to More investigation needed in Lints Triage Sep 19, 2023
@devoncarew devoncarew moved this from Under consideration to Triage backlog in Lints Triage Sep 26, 2023
@devoncarew devoncarew changed the title Consider enabling strict-casts in core or recommended enable strict-casts Sep 26, 2023
@devoncarew
Copy link
Member

From a discussion with @leafpetersen, he thought this was likely worth adding, if we can handle the special case for common patterns in web code.

@devoncarew devoncarew moved this from Triage backlog to More investigation needed in Lints Triage Feb 6, 2024
@lrhn
Copy link
Member

lrhn commented Feb 7, 2024

If we change the language to give another easy way to get a general downcast, or an explicit dynamic section of code where the mode won't apply, or specify specific workaround patterns, then it's OK to discourage uses that don't use those patterns. We have not done that yet.
I still don't think we're ready to effectively remove implicit downcasts from dynamic from the language.
We need an opt-in syntax, and preferably one which isn't too cumbersome, and which works correctly for something like for (int x in listOfDouble as dynamic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: More investigation needed
Development

No branches or pull requests

3 participants