-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fasta: Generalized void #30470
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
From talking with @lrhn it sounds like this will block the next wave of library changes. @kmillikin, @stefantsov, just wondering if there is a way we could/should move this forward in time. |
To be more specific, the next wave will include changes to asynchronous classes like Some methods return |
Do we have any tests of this? |
A quick search shows |
I need a list of the actual tests that the language teams has implemented to test this feature. I know how to do a quick search. |
Proposed fix: change 30760. |
I added a positive test here: https://dart-review.googlesource.com/c/sdk/+/30840. It's simply checking that expressions of type Edit: Landed in commit aa97656. |
NB: Change 30760 allows the
So it would be a fix for part of this issue, not all of it. But a partial fix is also useful, of course! |
Note: this is important for being able to run Flutter. That's why we are bumping priority. For the record there is a patch from @peter-ahe-google https://dart-review.googlesource.com/c/sdk/+/30760 |
I'm still short on tests of the new features, I do have tests of existing features that have been in Dart for years. |
Here are some tests in
There are other tests involving callFoo(A a) => a.foo(); where callFoo(A a) => a.foo() as dynamic; in which case it should still run successfully under the new rules. |
I believe that the most productive approach, for any given tool/configuration, would be to make |
@eernstg thank you, I'll give that a try. |
@peter-ahe-google Thank you! Note also #31883 which explains why some subtests in |
I have landed the CL, @peter-ahe-google you can close this issue. |
Thank you, @a-siva. Unfortunately, work still remains on producing the correct compile-time errors. |
In progress CL sorting out language tests here: https://dart-review.googlesource.com/c/sdk/+/66521 for reference. Tests under language_2/void have been triaged. |
tests have landed in https://dart-review.googlesource.com/c/sdk/+/66521 |
Is there anything further we need to do here? |
I'm still seeing CFE errors on void to void transfers, and this seems to be causing trouble with rolling flutter into fuschia. This example produces an incorrect error: void foo() {}
void main () {
void v = foo();
} The tests I landed don't seem to have been triaged yet. cc @tvolkert |
FYI, this is producing spurious warnings in the Fuchsia build (it causes issues with mockito's |
FYI: I made a mistake while revising the spec for void related returns that implied an undesired breaking change. I fixed the spec and the analyzer implementation, and adjusted the tests here: https://dart-review.googlesource.com/c/sdk/+/70462 . |
another user hitting this: dart-lang/mockito#163 |
For planning purposes, what's the status of this issue? Is a revert of https://dart-review.googlesource.com/c/sdk/+/66160 likely? Is the analyzer likely to change? Are the compiler warnings here to stay? Is the status quo likely to remain for the foreseeable future, or is something likely to change in the near term? |
Some of the compiler warnings should be errors, and some of them are bugs in the implementation (they are false positive warnings where there is no problem). 2a36502 fixed many of the false positive warnings, but not all of them. They were left as warnings. This CL should fix the remaining false positives and turn the genuine error cases back into static errors. I will ensure that I verify that the errors do not break anything in Flutter that I can see, and ensure the behavior is as intended according to the language team, before landing the fix. |
Thanks. Will there be an effort to make sure the analyzer reports at least all the errors that the compiler reports? One of the weird things we're dealing with right now is that the compiler complains about things that the analyzer is happy with. |
Yes, and I'll be the one to do that. From what I know, the missing errors in the analyzer here are extreme edge cases (like |
Great! We see a lot of these messages when running our tests (from mockito, I assume), so we are looking forward to these changes making those go away. Let me know if there's anything we can do to help. |
By my understanding of https://github.com/dart-lang/sdk/blob/master/docs/language/informal/invalid_returns.md this should be invalid:
It's a synchronous function and the return type is not Is that correct? |
Discussing this IRL, Kevin and I concluded that invalid_returns.md makes it an error: We go from 'Expression bodied functions', synchronous, to 'Block bodied functions', 'Synchronous', with In the case where we decide that it "should" have been a valid return, I believe the relevant adjustment would be to require ' The conceptual consideration here is that we may consider The opposite side of that coin would be to say that it is an error to perform case analysis on a value of type |
I agree with the interpretation. We did not go for "voidy" in the asynchronous cases either, and I'm not sure we should for the synchronous ones alone. This is a pure So, all in all, I'm not sure we need to change anything. |
Something seems off about that. I believe it's OK to write this (Dart 1 programmers do it all the time): Future<int> future;
...future.then((i) => print('done'))... If I notice that this same function is used multiple times, I might name it as a local function and I might declare a type for it. (In fact, I will declare a type for it because I want the type checker to validate my understanding and I want the type to serve as documentation.) I will just use the inferred type which is FutureOr<void> done(int i) => print('done');
...future.then(done)... Here the implementation will tell me that I have a static error which is an invalid return. But something's fishy about that, because all I did was move some code around and annotate it with its inferred type. So either (1) there's nothing wrong with this return or (2) there is, but not both. |
@Hixie the current status is that fixing the remaining false positive warnings for ETA is hopefully the end of this week. There doesn't seem to be any implementation problems to sort out. |
The front end is now passing the language_2 void and invalid returns tests. This was landed in 9bdf248. |
Well, actually the inferred type is These voidy warnings were something of a rabbit hole, so I'm hesitant to revisit them without some evidence that there is a real problem here. |
Until a few days ago the inferred type was static method main() → dynamic {
asy::Future<core::int> future;
future.{asy::Future::then}<void>((core::int i) → void => core::print("done"));
} |
This is the Fasta specific issue for issue #30176, which contains the details.
The text was updated successfully, but these errors were encountered: