-
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
[ddc] error on type checks for records #52480
Comments
Thanks for filing the issue - updated the title slightly. There are discrepancies in our subtyping check for records in DDC (dev-mode) compared to dart2js (production), but it appears it is specific to web numbers. Here is a similar program showing the issue: main() {
(double, double) a = (0, 0.1);
Object b = a;
b as (double, double);
} This fails with a cast error And this programs shows different results depending on the backend: main() {
Object a = (0, 0.1);
(double, double) b = (0, 0.1); // implicit conversion based on typing context
Object c = b;
// Prints on VM, dart2js, ddc
print(a is (double, double)); // false, true, false
print(a is (int, double)); // true, true, true
print(c is (double, double)); // true, true, false
print(c is (int, double)); // false, true, true
} The column on In particular, the following program correctly prints class A {} // mimic `double` on the web
class B extends A {} // mimic `int` on the web.
main() {
Object a = (B(), A());
(A, A) b = (B(), A());
Object c = b;
print(a is (A, A));
print(a is (B, A)); // mimic (int, double)
print(c is (A, A));
print(c is (B, A));
} |
See: #52480 Change-Id: Ife785a2f77579b93854779e43ac349342ac06af3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305480 Reviewed-by: Nicholas Shahan <nshahan@google.com>
Bug: #52480 Change-Id: Iad9f6c986d4c445558c105abc66ad9b2a2812f25 Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/305560 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306307 Reviewed-by: Sigmund Cherem <sigmund@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Mark Zhou <markzipan@google.com>
In DartPad, this prints
success
.In native, this prints
success
.In Flutter for Web, this throws the following error:
I'm using MacOS/Chrome however I have also tested on Windows10/Edge with similar results.
flutter --version
dart --version
Dart SDK version: 3.1.0-129.0.dev (dev) (Fri May 19 12:10:06 2023 -0700) on "macos_arm64"
The text was updated successfully, but these errors were encountered: