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

Prevent invalid code when removing assignment target of side-effectful object expression #3921

Merged
merged 1 commit into from Jan 6, 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 #3920

Description

As with all "simplification" type optimizations, this adds the necessary information so that when e.g. an object expression becomes an expression statement, it is wrapped in parentheses to avoid being misinterpreted as a block statement. Should also solve similar issues for sequence expressions.

@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#gh3920-invalid-object-expression

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

@codecov
Copy link

codecov bot commented Jan 6, 2021

Codecov Report

Merging #3921 (4c347e8) into master (966bfa5) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3921   +/-   ##
=======================================
  Coverage   97.08%   97.08%           
=======================================
  Files         187      187           
  Lines        6551     6554    +3     
  Branches     1909     1911    +2     
=======================================
+ Hits         6360     6363    +3     
  Misses        101      101           
  Partials       90       90           
Impacted Files Coverage Δ
src/ast/nodes/AssignmentExpression.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 966bfa5...4c347e8. Read the comment docs.

@lukastaegert lukastaegert merged commit 2365ece into master Jan 6, 2021
@lukastaegert lukastaegert deleted the gh3920-invalid-object-expression branch January 6, 2021 14:05
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.

Object literals in output causing syntax errors
2 participants