Skip to content

Fix for array constructor with length is not eliminated#4294

Open
maifeeulasad wants to merge 5 commits intogoogle:masterfrom
maifeeulasad:fix-array-constructor-length-maifee
Open

Fix for array constructor with length is not eliminated#4294
maifeeulasad wants to merge 5 commits intogoogle:masterfrom
maifeeulasad:fix-array-constructor-length-maifee

Conversation

@maifeeulasad
Copy link
Copy Markdown

closes #4046

Tested w

bazel test //:test/com/google/javascript/jscomp/PeepholeRemoveDeadCodeTest --test_filter=testArrayConstructor --test_output=all

@google-cla
Copy link
Copy Markdown

google-cla bot commented Jan 29, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@blickly
Copy link
Copy Markdown
Contributor

blickly commented Jan 30, 2026

Can you add unit tests for this new case alongside the existing unit tests of the similar new Array() cases in AstAnalyzerTest.java ?

In particular, including the .assumeBuiltinsPure(false) case is something we'd want to include

@maifeeulasad
Copy link
Copy Markdown
Author

@blickly absolutely. Planning to do it in the next 18 hours!

@maifeeulasad
Copy link
Copy Markdown
Author

@blickly care to take look into this please?

  • fixed breaking test case
  • added builtin assumption to both true and negative for array

Current testing commands are:

bazel test //:test/com/google/javascript/jscomp/AstAnalyzerTest --test_output=all
bazel test //:test/com/google/javascript/jscomp/PeepholeRemoveDeadCodeTest --test_filter=testArrayConstructor --test_output=all

Running the whole thing just to confirm CI doesn't complain any more with, if I find any issues I will resolve in upcoming commits

bazel test //... --test_output=errors

@maifeeulasad
Copy link
Copy Markdown
Author

All tests are passing with

bazel test //... --test_output=errors

@blickly
Copy link
Copy Markdown
Contributor

blickly commented Feb 11, 2026

Can you put the new unit tests alongside and match the style of the existing tests of new Array having side effects?

@maifeeulasad
Copy link
Copy Markdown
Author

image

Sorry. I used the exact style I found in ast analyzer, both for positive and negative test. And I already moved the tests into this existing file, where other ast related test lies. Do you want me to move them into some other files? Sorry I couldn't understand. But I am willing to complete this and get it done. Care to explain a bit more please?

@blickly

ref:

@maifeeulasad
Copy link
Copy Markdown
Author

Does it require any additional attention? Please let me know if it requires any other modifications or anything like that.

@blickly

@blickly
Copy link
Copy Markdown
Contributor

blickly commented Mar 31, 2026

Sorry, I meant the tests in the test case called MayEffectMutableStateTest. Do you see how there are existing parameterized test cases that already test new Array? Can we put the new tests alongside those existing ones?

@maifeeulasad
Copy link
Copy Markdown
Author

All done! Care to take a look into it again for me please??

Eagerly waiting for feedbacks and open to comply!

cc: @blickly

@blickly
Copy link
Copy Markdown
Contributor

blickly commented Apr 7, 2026

If you remove all your changes to src/com/google/javascript/jscomp/AstAnalyzer.java, which of the tests fail?

@maifeeulasad
Copy link
Copy Markdown
Author

If you remove all your changes to src/com/google/javascript/jscomp/AstAnalyzer.java, which of the tests fail?

Nothing fails.


Sorry I missed it, cause I jumped into it.

due to the following lines, it is already working:

Do I raise another MR with just the tests introduced? Or do we continue here? What shall we do next??

cc: @blickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array constructor with length is not eliminated

2 participants