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
When inlining functions using rest arguments Terser sometimes tries to spread a rest argument into a variable, which is invalid Javascript. In the example below, it seems that Terser has missed that identity is only using its first argument.
Version (complete output of terser -V or specific git commit)
function identity(x) {
return x
}
function outer(keyFn) {
return function inner(...args) {
const key = keyFn(...args)
console.log(key)
}
}
outer(identity)(1)
terser output or error
!function(...o){const n=...o;console.log(n)}(1);
Expected result
!function(...o){const n=o[0];console.log(n)}(1);
or
!function(o){const n=o;console.log(n)}(1);
The text was updated successfully, but these errors were encountered:
jpdutoit
changed the title
Inlining function with rest argumentsleads to invalid code being generated
Inlining function with rest arguments leads to invalid code being generated
Jul 19, 2022
Bug report
When inlining functions using rest arguments Terser sometimes tries to spread a rest argument into a variable, which is invalid Javascript. In the example below, it seems that Terser has missed that
identity
is only using its first argument.Version (complete output of
terser -V
or specific git commit)https://try.terser.org
Complete CLI command or
minify()
options usedterser
inputterser
output or errorExpected result
or
The text was updated successfully, but these errors were encountered: