-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Function considered pure with call site annotation, but not with pure_funcs #3065
Comments
Confirmed bug.
Strangely, disabling
|
@rtfeldman thanks for the detailed report 👍 @kzc we have single-use |
It ought to be additionally gated by either |
|
My last comment was unrelated to
|
Notice that |
@kzc yes I know what you are talking about - and I'm saying the example you've just pasted above isn't inlined. An inlined function would not be of the form |
So other than disabling |
The only difference between |
Thanks for the quick turnaround on this! 😍 I noticed the example in the original is still reproducible if Is that intended behavior? I saw the commit mentioned "Make sure symbols under Is there an underlying technical reason pure functions can't be mangled? |
Simply for the fact that |
Ohhh, got it! So Does that mean if I wanted to mangle pure functions, I could run once or twice without mangling to complete all the DCE, and then do one final pass with mangling fully enabled to mangle all the pure functions? |
That's one way of doing it, yes. |
Gotcha! Is there a more recommended way to do it? (e.g. a way to run |
To the average user it looks like function inlining - the original function declaration is no longer present. That's what We'll have to disagree on this point. Enough said.
That's actually a bug/regression. Case in point:
Compare latest master b82fd0a:
to 2.x:
As a workaround
Notice that function |
Bug report or feature request?
Bug report
ES5 or ES6+ input?
ES5
Uglify version (
uglifyjs -V
)uglify-js 3.3.20
JavaScript input
The
uglifyjs
CLI command executed orminify()
options used.JavaScript output or error produced.
This was the output:
However, there should have been no output because:
pure_funcs="pureFunc"
, uglify should considerpureFunc
a pure function.pureFunc
is only called once, and that result is assigned to an unused variable.It works as expected if I add a
/*@__PURE__*/
annotation at the call site, such that the last line becomesvar unused = /*@__PURE__*/pureFunc(function(x) { return x; });
- adding that annotation and re-running uglify results in the correct result (of no output).However, annotating every
pureFunc
call site with/*@__PURE__*/
should not be necessary, sincepureFunc
was listed inpure_funcs
!The text was updated successfully, but these errors were encountered: