Skip to content

Inconsistency in generic function type equality between Dart VM and webdev #33926

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
vincentvanpeer opened this issue Jul 20, 2018 · 2 comments
Closed
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler

Comments

@vincentvanpeer
Copy link

Dart 2.0.0-dev.69.0 (Unknown timestamp) on "linux_x64"

https://github.com/vincentvanpeer/dartfunctiongenericbug contains a method that prints the equality between a type def and a generic type, which in the implementation of both the test and the webapp, contains the same type def.

When running the unit test, both in the VM and in Chrome, I get the same expected result.

$ pub run test
00:01 +0: loading test/lib_test.dart                                                                                                                                                                                                                          
T == MyFunction: true
No tests ran.
$ pub run test -p chrome
00:07 +0: compiling test/lib_test.dart                                                                                                                                                                                                                        
Compiled 8,664,184 characters Dart to 939,849 characters JavaScript in 7.07 seconds
Dart file (/tmp/dart_test_IEORVD/runInBrowser.dart) compiled to JavaScript: /tmp/dart_test_CIQGJI/test_ECSRIO/lib_test.dart.browser_test.dart.js

T == MyFunction: true
No tests ran.

However if I run the web code in Chrome, as shown below, the console prints T == MyFunction: false

$ pub global run webdev serve
[INFO] Setting up file watchers completed, took 31ms
[INFO] Waiting for all file watchers to be ready completed, took 49ms
[INFO] Building new asset graph completed, took 880ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Running build completed, took 3.9s
[INFO] Caching finalized dependency graph completed, took 161ms
[INFO] Succeeded after 4.1s with 14 outputs (1503 actions)
Serving `web` on http://localhost:8080
Serving `test` on http://localhost:8081

This is inconsistent. I would expect the condition to return true in Chrome as well.

@lrhn lrhn added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler labels Jul 20, 2018
@natebosch
Copy link
Member

dart2js, vm, and ddc all agree on this now. Equality is based on the function type, not the typedef name.

@eernstg
Copy link
Member

eernstg commented Apr 26, 2019

Note that the test mentioned here is a less comprehensive version of the one mentioned in #32782, which is still open (and tests/language_2/type_alias_equality_test.dart incurs a run-time error where it shouldn't, for at least several configurations of the vm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler
Projects
None yet
Development

No branches or pull requests

4 participants