Skip to content

Warning for multiple equal imports with hide combinator #59907

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

Closed
FMorschel opened this issue Jan 14, 2025 · 4 comments
Closed

Warning for multiple equal imports with hide combinator #59907

FMorschel opened this issue Jan 14, 2025 · 4 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-warning Issues with the analyzer's Warning codes P3 A lower priority bug or feature request

Comments

@FMorschel
Copy link
Contributor

Coming from @bwilkerson's comment on #56830:

In the sense that we have two imports with the same URL.

I will point out that having two or more imports of the same URI, all with either hide or no combinator and all having the same prefix, means that the only thing hidden is the intersection of the hide lists. [...] More useful than a fix would be a warning that these hide clauses are not really hiding anything.

I'm opening this issue to track this warning.


Somewhat related to both #56879 and #59722.

@FMorschel
Copy link
Contributor Author

I've decided to add exports to this request too.

We should also consider when having both hide and another equal import with no combinators (or with show containing the same names) to let the user know the hide is not doing anything.

I'll change the request over at #59722 a bit for the show part which I'd agree is also needed but with different levels of importance so this can be done separately.

@scheglov scheglov added P3 A lower priority bug or feature request devexp-warning Issues with the analyzer's Warning codes labels Jan 17, 2025
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 27, 2025
@FMorschel
Copy link
Contributor Author

The more I think about this warning, the more it feels like a specific case of "redundant" imports (#44569). Any takes here @srawlins since you opened that issue?

Do you think this is worth a specific warning or we better do it all together? If we endup with a fix for this in either this warning or the "redundant" one, I'd say nothing would change for the user.

@srawlins
Copy link
Member

Yeah I think it is a case of "redundant" imports.

It's probably better to just have one warning for redundant imports. Yeah I don't think anything changes for the user. I don't think it's high enough value to have specific messaging like "the only thing hidden is the intersection of the hide lists." although that is a fairly comical situation to get into.

@FMorschel
Copy link
Contributor Author

although that is a fairly comical situation to get into.

I agree. But not long ago we had some problems with the "Import library" fixes to update hides and shows as well as the auto-complete (I've been fixing them on the last months, unless new things show up they should be fine now) so if:

  • Originally some element was exposed with a different name in a second library and you added the original hide
  • Now some other programmer needed that declaration (after the other declaration rename), if the person is not familiar with the structure, copied the import from somewhere else and missed that.
  • If more than one thing was hidden originally, they might need to add the hide on the new import too for things to work.

But yes, if not some similar case to this, I can't think of a way to get here.

Yeah I think it is a case of "redundant" imports.

Closing this in favour of that issue (#44569) then. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-warning Issues with the analyzer's Warning codes P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

4 participants