You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
export const exp=o=>1;export function smoothDamp(o=t){const t=o(10)}
Expected result
export const exp=o=>1;export function smoothDamp(o=exp){o(10)}
t in the output is undefined in global scope. In our case, it appears that it was getting assigned to another function -- leading to some really weird stuff. However, in the original case, it just doesn't work. By changing const exp to const e, the param default is handled correctly as exp.
Now, if you change const exp = easing(10); to be const e = easing(10); , you get correct output:
This is indeed a bug. And an incredibly hard one to fix. I think this is because there's a scope for the function's default parameters, and another for the function's variables. Thanks for reporting!
Bug report
While we encountered this in our codebase, I can also repro with https://try.terser.org/
Version (complete output of
terser -V
or specific git commit)Complete CLI command or
minify()
options usedterser
inputterser
output or errorExpected result
t
in the output is undefined in global scope. In our case, it appears that it was getting assigned to another function -- leading to some really weird stuff. However, in the original case, it just doesn't work. By changingconst exp
toconst e
, the param default is handled correctly asexp
.Now, if you change
const exp = easing(10);
to beconst e = easing(10);
, you get correct output:A coworker happened to try with esbuild:
https://esbuild.github.io/try/#dAAwLjE5LjgALS1taW5pZnkAZXhwb3J0IGNvbnN0IGV4cCA9ICh0KSA9PiAxIDsKCmV4cG9ydCBmdW5jdGlvbiBzbW9vdGhEYW1wKGVhc2luZyA9IGV4cCkgewogIGNvbnN0IGV4cCA9IGVhc2luZygxMCk7IAp9
The text was updated successfully, but these errors were encountered: