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

Remove folding Array.prototype.concat (fix #577) #578

Merged
merged 2 commits into from Jun 14, 2017

Conversation

boopathi
Copy link
Member

No description provided.

@boopathi
Copy link
Member Author

/cc @j-f1

@codecov
Copy link

codecov bot commented Jun 14, 2017

Codecov Report

Merging #578 into master will increase coverage by 0.16%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #578      +/-   ##
==========================================
+ Coverage   82.86%   83.02%   +0.16%     
==========================================
  Files          44       44              
  Lines        2900     2928      +28     
  Branches     1012     1022      +10     
==========================================
+ Hits         2403     2431      +28     
  Misses        303      303              
  Partials      194      194
Impacted Files Coverage Δ
...plugin-minify-constant-folding/src/replacements.js 96.61% <ø> (-0.22%) ⬇️
packages/babel-plugin-minify-builtins/src/index.js 92.3% <0%> (+2.51%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78c8208...3c8a3a2. Read the comment docs.

@boopathi boopathi added the Tag: Bug Fix Pull Request fixes a bug label Jun 14, 2017
Copy link
Contributor

@j-f1 j-f1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple comments:

@@ -107,9 +107,6 @@ describe("constant-folding-plugin", () => {
it("should handle Array methods on array literals", () => {
const source = unpad(
`
[1, 2, 3].concat([4, 5, 6]);
[a, b, c].concat([d, e], f, g, [h]);
[1, 2, 3]["concat"]([4, 5, 6]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to test this with push since you’re removing it:

[1, 2, 3]["push"]([4, 5, 6])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

return t.arrayExpression(
this.elements.concat(
...args.map(arg => {
if (t.isArrayExpression(arg)) return arg.elements;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to check if any of these are variables instead of removing this entirely? For example, [a, b, c].concat([1, 2, 3]) is safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really common to use constants here in concat ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess not.

Copy link
Contributor

@j-f1 j-f1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tag: Bug Fix Pull Request fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants