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

bug: possible side effect in optional param is ignored #880

Open
vankop opened this issue Nov 23, 2020 · 5 comments · May be fixed by #1148
Open

bug: possible side effect in optional param is ignored #880

vankop opened this issue Nov 23, 2020 · 5 comments · May be fixed by #1148
Labels

Comments

@vankop
Copy link

vankop commented Nov 23, 2020

Bug report or Feature request?

bug report

Version (complete output of terser -V or specific git commit)

latest repl

Complete CLI command or minify() options used

{
  module: true,
  compress: {},
  mangle: {},
  output: {},
  parse: {},
  rename: {},
}

terser input

Снимок экрана 2020-11-24 в 00 57 32

@fabiosantoscode
Copy link
Collaborator

Cool, thanks for reporting!

@WofWca
Copy link
Contributor

WofWca commented Jun 30, 2021

Reduced example

Complete CLI command or minify() options used

{
  module: true,
}

terser input

function causeSideEffect(a = console.log('sideEffect')) {}
causeSideEffect();

terser output or error

<nothing>

Expected result

console.log('sideEffect')

@fabiosantoscode
Copy link
Collaborator

Appreciate it!

@WofWca
Copy link
Contributor

WofWca commented Jul 4, 2021

I'm working on this currently, it's going OK, but don't expect too much as I'm not very familiar with the code base.

@fabiosantoscode
Copy link
Collaborator

It seems pretty hard to me, after writing a test and trolling through the code. Side effects in default assignments have to be treated specially, but there's lots of places where arguments are just assumed (without calling any methods to find out) to have no side effects.

WofWca added a commit to WofWca/terser that referenced this issue Feb 16, 2022
WofWca added a commit to WofWca/terser that referenced this issue Feb 17, 2022
WofWca added a commit to WofWca/terser that referenced this issue Feb 17, 2022
WofWca added a commit to WofWca/terser that referenced this issue Feb 17, 2022
WofWca added a commit to WofWca/terser that referenced this issue Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants