Skip to content

Duplicated identifier used when mangle is enabled #1155

@renanccastro

Description

@renanccastro

Bug report

Terser is using the same identifier for the function, and for the const defined inside the if. This produces code that can't be evaluated.

Here is a simple reproduction case:

function f1() {
	if (true) {
		function f2() {
			return 1;
		}

		const var1 = 666;
	}
}

If var1 is outside the "if", the correct identifier is used when minifying.

Used options:

{
  module: true,
  compress: {
    unused: false
  }
}

Curent terser output

function n(){{function n(){return 1}const n=666}}

note the inner function n() and the const n, they clash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmangleIssue in the mangler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions