-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Two ShowCombinator
s and two HideCombinator
s should have error
#56879
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
Comments
Summary: The analyzer fails to detect an error when two |
You never need more than one Here the second |
@bwilkerson I'll add the tests you asked for at https://dart-review.googlesource.com/c/sdk/+/404525 but just so you have this in mind please take a look at the first comment here from @lrhn. |
I completely agree with Lasse's comment. But unless we're going to make it a compilation error for users to have more than one combinator, I think we need to support (as in, don't break) users that don't follow what we consider to be reasonable best practices. |
Here is the CL for this https://dart-review.googlesource.com/c/sdk/+/413520 |
While working on the description for the new diagnostic, I came up with this example: import 'dart:math' show Random, max, min show min;
var x = min(0, 1); But the above triggers I was thinking of the original example: import 'dart:core' show List show int hide String; // Notice the multiple combinators but no analyzer error
void foo(List<int> list, String str) {} The important take here is that there is no analyzer error on the import line but no type can be resolved. I think So I guess to be more explicit, after this CL lands, I'd say:
|
Having a fix (or two) sounds reasonable. I also prefer using
Agreed. Users don't need two warnings for the same problem. Should we continue to produce it if the new warning is disabled? I'm undecided at this point.
If it's a compilation error then we're required to produce it. If it's a warning, then you'll need to be more specific about which error in order for me to have an opinion. |
Alright then. I was only thinking of giving them different "priorities" depending on the code the user has but without them being assists, I don't think there is a way for us to do that. Not a problem, it would just be a better UX I think. Say: import 'dart:math' show Random, max, min hide min;
import 'dart:math' hide Random, max, min hide min; The first import would prefer the
I know it allows the users to know they have not used names but the names can't be used. So I'm not sure either. I always feel like it is telling me to use that name rather then maybe removing it from the list.
Take this as an example: import 'dart:math' show max show min; We have no |
Makes sense.
We can tailor the correction message to the situation if we decide to continue to produce the warning.
True, but the language doesn't specify this to be an error, so there should be no diagnostic specific to it. The proposed warning would already flag this case. It sounds like the cases are covered. Is there a case where neither the proposed warning nor an existing diagnostic would be produced? |
I don't think so, no. We should be fully covered with the new warning. |
Bug: #56879 Fixes: #60309 Change-Id: Ifac77bbcb0d22c96cc01ea12fba1af86721809e2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414800 Reviewed-by: Phil Quitslund <[email protected]> Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
If you have the following code:
Not
List
,int
orString
(of course) is correctly analysed showing errors likenon_type_as_type_argument
.But if we remove the second
show
and add a,
it works as expected.I believe we should have an error message about writing down two
show
s or twohide
s if they make everything else stop working.The text was updated successfully, but these errors were encountered: