-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Analyzer/Frontend inconsistency - type arguments after named constructor #34403
Comments
It's an error, and should not be accepted by either tool. The former syntax was accepted when we introduced generic methods, but since |
I'm not sure how to label/triage this issue. I'm guessing CFE since its an error in the analyzer. |
They are both missing the error when you omit the |
The analyzer will not be implemented in terms of CFE in the 2.1 timeframe, so it needs to be implemented in both places. It would be good to have separate issues for the two areas. |
Note that by fixing this we'll start to reject code that previously ran fine so it could break some projects. I suspect we'll want to do that anyway, but can the language team please confirm that we want to move forward? |
The implicit new case still doesn't work. Might be implicitly covered by 34159, but not explicitly covered by the other cases. Reopening. |
What's the status of this? We'll need to give users a heads up that there's a breaking bug fix coming down the pipe. Should we consider leaving this as a warning for a few dev releases? |
Are you asking about status in CFE, or Analyzer? |
Looks like CFE doesn't fail on this yet so other than failing travis analyzer tests I don't think this should have a huge impact on flutter users yet. This will currently be breaking for DDC users. If we make it a warning then DDC users won't be broken right on SDK update. |
@keertip have you found any third party packages affected by this? |
Have not seen any third party packages affected by this. There is some internal code, DDC targets that fail due to this, not third party. |
Ok, I see two options.
Either way, I think we need a little breathing room. @scheglov can you please demote this to a warning for now? |
OK, this CL will make it a warning. |
Per #34403 (comment) request. R=brianwilkerson@google.com Change-Id: I9a2c319d2262aacf14bfc180d59d16db3f199a2a Reviewed-on: https://dart-review.googlesource.com/74560 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
I think it should be an error, and the sooner the better. I doubt any code was "running fine" using this syntax since the code has no semantic meaning. Any code that gets away with writing this has no specified semantics. It is no more correct than applying type parameters to a non-generic function, and then calling it anyway and saying that the code "works". Also, I very much want to introduce generic named constructors, and any leniency towards code that already uses that syntax will just delay breaking for that code until we actually start introducing a real meaning for it. That is not helping anyone. |
I think that would be fine, I'm not sure if we typically keep those types of differences between dev and stable though - have we done it before?
It is treated by the VM and Dart2JS as if it does have the semantic meaning the user expected. class Foo<T> {
Foo.named();
void printType() => print(T);
}
void main() {
Foo.named<String>().printType();
} Prints "String" with VM and Dart2JS.
I agree that it's worth fixing to buy back the syntax for generic named constructors. Rushing in to breaking code that works today is what has me nervous. |
@danrubel This could also be an interesting use case for fixit tool. |
@natebosch do you have the time to shepherd the fix for this? I think we need to:
|
The changes in the CFE are going to be the ones that are most impactful to the ecosystem. I think things would go the most smoothly if the rollout is managed by someone from the CFE team. |
This looks like an excellent example for an auto-fixup tool. @danrubel - wdyt? |
It's on my list after the class to mixin fixup |
Thanks! What do you all think about using the auto-fixup tool to drive the rollout? |
@askeksa-google has a fix for this in the CFE. It sounds like we want to wait on this until we have a fixup tool? @danrubel what is the approximate time frame you see for having a tool for this? I'm somewhat inclined to push to get this fixed in time to get into the flutter 1.0 build, even if that means landing it in dev before we have the tool. |
It's working in rough form to auto-fix class to mixin. For example:
I still need to hook it into the SDK. |
Tasks:
|
The CFE fix is ready at https://dart-review.googlesource.com/c/sdk/+/78080. The status file changes will probably conflict with the analyzer fix. But in the end, they should just eliminate all #34403 and #34671 entries. |
For breaking bug fixes like this, is it an option to make it an error in the analyzer, but only a warning in the CFE (compilers) for a while. That would allow existing code to keep running, but not without being clearly marked as wrong by the analyzer. |
Decision: land this, whether the tool is ready or not. |
Dart 1 VM did not accept the second form.
It would be breaking to make the first form an error since it has no error in either place. The inconsistency between including or not including
new
is jarring.The text was updated successfully, but these errors were encountered: