Skip to content

dart2js TypeImpl overrides operator == #17207

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
floitschG opened this issue Feb 28, 2014 · 10 comments
Closed

dart2js TypeImpl overrides operator == #17207

floitschG opened this issue Feb 28, 2014 · 10 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@floitschG
Copy link
Contributor

The equality operator is overridden for dart2js' Type implementation TypeIpml.

This means that it cannot be used in switch statements or as keys in constant maps.

See issue #15295 and issue #17123.

@floitschG
Copy link
Contributor Author

It's not clear if this is a bug or not. The VM does not override it, and this leads to incompatibility between VM and dart2js.

@rakudrama
Copy link
Member

Marked this as being blocked by #21553.

@floitschG
Copy link
Contributor Author

Issue #23009 has been merged into this issue.


cc @karlklose.
cc @johnniwinther.

@jakemac53
Copy link
Contributor

Just ran into this as well. It seems pretty clear to me that this is a bug because it causes programs which are completely valid in the vm to fail in dart2js.

@lexaknyazev
Copy link
Contributor

Apparently, this is somehow fixed with CFE.

@sigmundch
Copy link
Member

Note - the CFE is missing some compile-time errors. I believe this is not actually fixed, since we still override == in our implementation of Type, so I expect this error should be visible again in the near future.

@sigmundch
Copy link
Member

I just filed #32557 reporting why the CFE is not handling this error at this time. The underlying issue in dart2js remains, so I recommend not using Types as const keys or values on switch cases at this time, since it will be an error again soon.

@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 20, 2019
@rakudrama
Copy link
Member

The language specification currently treats type literals specially:

"Every instance of type Type which was originally obtained by evaluating a constant type literal
has a primitive operator ==."

I read this as permitting TypeImpl to override ==, but the implementation is known to the compiler and runtime, just like the implementation of Object.== is known to the compiler and runtime, so constant type literals are permitted as case expressions and constant map keys.

@sigmundch
Copy link
Member

We are very close to be able to mark this issue as fixed.

The new RTI is now enabled by default since 2.8.0-dev.1.0. This already makes switch cases work properly because our types are properly canonicalized. One issue remains is that we still override operator== in _Type (the equivalent of TypeImpl in the new RTI), but given our canonicalization rules we should be able to remove that.

@rakudrama - @fishythefish and I assume that's safe to remove at this point, correct?

@sigmundch
Copy link
Member

== was removed in 3c2a6c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

7 participants