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

Do not create invalid code if a function argument is an empty object pattern #3998

Merged
merged 1 commit into from Mar 16, 2021

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:
Resolves #3997

Description

When a function argument is an empty object pattern, Rollup would see that no variables are declared and falsely assume that it is not necessary. This fix adds special handling for that case (note that when even a single, even unused, variable was declared in the pattern, it was retained correctly).

@rollup-bot
Copy link
Collaborator

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#gh-3997_empty_object_destructuring

or load it into the REPL:
https://rollupjs.org/repl/?circleci=14534

@codecov
Copy link

codecov bot commented Mar 16, 2021

Codecov Report

Merging #3998 (25dc45e) into master (770da18) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3998   +/-   ##
=======================================
  Coverage   97.22%   97.22%           
=======================================
  Files         191      191           
  Lines        6743     6745    +2     
  Branches     1969     1970    +1     
=======================================
+ Hits         6556     6558    +2     
  Misses         99       99           
  Partials       88       88           
Impacted Files Coverage Δ
src/ast/scopes/ParameterScope.ts 100.00% <100.00%> (ø)

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 770da18...25dc45e. Read the comment docs.

@lukastaegert lukastaegert merged commit 9cae40d into master Mar 16, 2021
@lukastaegert lukastaegert deleted the gh-3997_empty_object_destructuring branch March 16, 2021 05:44
This was referenced Mar 16, 2021
This was referenced Mar 18, 2021
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.

Incorrect optimization of empty object destructuring in function parameters
2 participants