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

Variable self assignment not removed (x = x) #1081

Closed
Ahnfelt opened this issue Oct 5, 2021 · 4 comments
Closed

Variable self assignment not removed (x = x) #1081

Ahnfelt opened this issue Oct 5, 2021 · 4 comments
Labels
compress Issue in the compression step enhancement

Comments

@Ahnfelt
Copy link

Ahnfelt commented Oct 5, 2021

Bug report or Feature request?

Feature request.

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

Online REPL 5th of October 2021

Complete CLI command or minify() options used

Default options:

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

terser input

export function f(x) {
    x = x;
}

terser output or error

export function f(f){f=f}

Expected result

export function f(f){}
@jridgewell
Copy link
Collaborator

Do you see code like f = f as the output of some build step?

@fabiosantoscode
Copy link
Collaborator

fabiosantoscode commented Oct 7, 2021

Sometimes Terser itself outputs x=x IIRC

@Ahnfelt
Copy link
Author

Ahnfelt commented Oct 7, 2021

Sometimes Terser itself outputs x=x IIRC

Yeah, e.g. this produces the exact same output:

export function f(x) {
    const y = x;
    const z = y;
    x = z;
}

@jridgewell jridgewell added compress Issue in the compression step enhancement and removed discussion labels Oct 7, 2021
@jridgewell
Copy link
Collaborator

Alright, let's add a simple assignment case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compress Issue in the compression step enhancement
Projects
None yet
Development

No branches or pull requests

3 participants