Skip to content
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

dart2js -O1 breaks angular tests - then dead code fixes it O_o #44729

Open
daniel-v opened this issue Jan 21, 2021 · 1 comment
Open

dart2js -O1 breaks angular tests - then dead code fixes it O_o #44729

daniel-v opened this issue Jan 21, 2021 · 1 comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dart2js

Comments

@daniel-v
Copy link

I'm not sure if it is dart2js or angular_test related issue. Due to lack of better idea, I'm pretty much duplicating angulardart/angular#1952 here too.

Basically what I have observed is that having a bit of specially prepared dead code influences the compilation/optimization process of dart2js in such a way that it makes things work. I expect my code to work without the dead code but it doesn't. Without further ado, repro code here

Repro steps:

  1. grab a stagehand angular starter project
  2. throw in the test and the build.yaml file from gist
  3. pub run build_runner test -r -- -p chrome

-r command line argument is important. DDC works fine.

There are a number of things that must be present in order for this to happen:

  1. Component should use AsyncPipe on a special Stream
  2. The implementation of that Stream must be "mockito-like" - overriding noSuchMethod
  3. dart2js compiler must have -O1 or above optimization level

Until this point, component test fails, though I think it should pass. To fix it, there are 2 approaches:

  1. add a bit of dead code like in the gist
  2. use -O0 optimization level for dart2js

My expectation:
Both reachable tests pass without dead code

What happens:
Without dead code, the component test fails, though it shouldn't

Env

  • Dart SDK version: 2.10.4 (stable) (Wed Nov 11 13:35:58 2020 +0100) on "linux_x64"
  • Angular 5.3, 6

Uhm, so I'm wondering, is it an angular_test bug or did I stumble onto something compiler related? (There is a 3rd option: I'm a idiot and I'm missing something)

@daniel-v
Copy link
Author

(hihi, had my fun, wonder if this workaround will pass CR: https://gist.github.com/daniel-v/e734a6b5f0f5ba5ead26130ddc67cb93 )

@mraleph mraleph added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dart2js labels Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dart2js
Projects
None yet
Development

No branches or pull requests

2 participants