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

renames arrow function declaration despite keep_fnames: true #1522

Open
samualtnorman opened this issue Apr 25, 2024 · 2 comments
Open

renames arrow function declaration despite keep_fnames: true #1522

samualtnorman opened this issue Apr 25, 2024 · 2 comments

Comments

@samualtnorman
Copy link

samualtnorman commented Apr 25, 2024

image

In the source, the function is named foo and inspecting its .name gives foo.
However terser mistakenly renames the function to bar which can be observed with .name.
In the screenshot I run the before minified and after minified and you can see in the console what console.log()ing the .name gives.

the source is

let foo = () => {}
let bar = foo

console.log(bar.name)
@fabiosantoscode
Copy link
Collaborator

fabiosantoscode commented Apr 28, 2024

The circumstances where .name is assigned are statically analyzable (we can list the circumstances by searching for references to NamedEvaluation in the spec) so this is something that can be done.

We can for instance suppress the analysis of variable definitions that hold anonymous functions here. This approach is simple but it may have drawbacks (IE we can't inline functions into callsites now).

@fabiosantoscode
Copy link
Collaborator

Related: #1484

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

No branches or pull requests

2 participants