-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fasta: Type
values obtained from a typedef should represent the underlying type, not the typedef
#31359
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
Fasta is correct. The |
Thanks @lrhn for clarifying. If that is the case, this might mean we need to fix all implementations to match the structural equality. I believe right now both the VM and dart2js have the nominal semantics. We have also seen angular apps that use typedefs as keys in DI maps and that might break if we change this. /cc @hterkelsen - do you know how much of a breaking change this would be? |
For the record, the Fasta behavior is likely the result of a mail discussion we had between the Kernel and language teams (and probably a few other people) back in January about the shortcomings of the specification around The specification, and class documentation, is silent on, well, everything. The entirety of the documentation on The specification tells us how to create
That's vague enough that I can't decide whether In either case, there is not enough specification to make any behavior formally right or wrong. There is, however, desirable behavior, and if the typedef F();
class C<T> { get type => T; } // Another way to extract a type.
main() {
print(F == new C<F>().type);
} If this doesn't print It prints Another example: typedef F();
typedef G();
main() {
print(<F>[].runtimeType == <G>[].runtimeType);
} Again, I'd want this to be true. It's true in dart2js, false in the VM. |
I'll try to get some numbers on if we have customers making use of the "declaration interpretation" |
we are still investigating whether the fix should be in dart2js instead - I've marked this as "low" to indicate somehow that this is not something the FE team should actively look into yet. |
Is this issue fixed (as in |
I suspect that the current title ('Do not convert typedefs used as values to a type') is misleading given that the goal is now to ensure that |
Type
values obtained from a typedef should represent the underlying type, not the typedef
Yes - I think we can close this issue as working as intended |
Are you sure it is working? I just checked, and here's an excerpt from a trybot log, showing that the configuration includes
The message The failing trybots were dart2js-linux-d8-kernel-minified-try, ddc-linux-release-chrome-try, vm-kernel-mac-release-x64-try, vm-linux-release-x64-try, and vm-mac-release-x64-try (there were some other failures, but they all fail on the test I'm adding in this CL: 'type_alias_equality_test.dart'), so we might need to create a meta bug, or change this to a meta bug, such that we can handle the issue with other tools (e.g., ddc) as well. |
I've written a test for this, added in c98df5b. Status file updates are included in that commit, because several tools fail to pass the test (currently dart2js, dartdevc, fasta, and the vm fail, at least in some configurations). Given that this affects several tools, I've created a new meta-bug #32782 for this, and this issue is henceforth the fasta specific issue for #32782. I updated the initial comment on this issue to to say so. This issue used to have the label |
Type
values obtained from a typedef should represent the underlying type, not the typedefType
values obtained from a typedef should represent the underlying type, not the typedef
Type
values obtained from a typedef should represent the underlying type, not the typedefType
values obtained from a typedef should represent the underlying type, not the typedef
The point is that #32782 requests a fix such that `typedef F1 = void Function(int)` and `typedef void F2(int)` satisfy that `F1 == F2` evaluates to true. This is marked 'p3-low' for the common front end but 'p1-high' for DDC. It seems likely to me that this could create the situation where code is developed using DDC, is working, and then fails upon deployment using the vm. Also, there is a single case where `dart2js` fails in the associated `type_alias_equality_test.dart`, so deployment on the web would also fail upon deployment, though only in some of the cases. However, with some input from Aske I concluded that the situation might have arisen because there _is_ no work to do for this in the common front end, because it will be handled by the backend (which also explains why `dart2js` has it almost right). This CL is just introducing a tiny change: It changes the issue indicated for all VM related failures in said test to point to #32783, which is presumably the right issue for backend work. Apart from that, I've added you, the reviewers, in order to make sure that the relevant people get this heads up. We may then decide to land this CL, change the priority on #31359, do nothing, or whatever turns out to be the right response. ;-) Change-Id: I92672547d7fe795e877604c0da1e0e4579e4e04a Reviewed-on: https://dart-review.googlesource.com/74403 Reviewed-by: Jenny Messerly <[email protected]>
FYI: The language specification has been clarified to specify explicitly that ' |
Edit by eernstg, Apr 6 2018: This is now the fasta specific issue for #32782.
We represent typedefs as function types when the typedef is used as a value. This is problematic because it breaks when using the
==
operator and printing.Here is simple repro:
Running this prints
F
andfalse
on the VM, but() => int
andtrue
if using fasta.For context - this issue was discovered while trying to compile an app with dart2js, I don't believe there is a work around on our side.
The text was updated successfully, but these errors were encountered: