Bug report or Feature request?
Regression bug.
Version (complete output of terser -V or specific git commit)
Regression point:
commit 2889744e409fa919abae195d00da926f51e980fb
Author: F谩bio Santos <[email protected]>
Date: Mon Dec 23 00:41:36 2019 +0000
improve inlining
Complete CLI command or minify() options used
# apply pull request #542 to get fuzz.js working after Acorn 7 upgrade
npm run build
node test/fuzz.js
terser output or error
Example run:
$ node test/fuzz.js
"";
">6";
export default class ohgoxshajhn {
static set [null] ([, [], , ...p] = (super[new.target] <<= new.target) == "F") {
class k {
static [/k\u457d\B/giuy]() {}
static get [(0)]() {}
static set [k] (v) {
"use strict";
}
static get [""]() {}
}
}
static [2e308](ptbewuqujkw, iqlnwhrnf, jhtxfhxljwlrmv, sypkxlsjs) {
"&矛谩T"
"x";
"use strict"
debugger;
return;
}
}
import udyiif, * as pavhomwljuu from "卯脩]";
export {}
/terser/test/fuzz.js:56
throw result.error;
^
RangeError: Maximum call stack size exceeded
at Tn.before (/terser/dist/bundle.min.js:1:178002)
at AST_SymbolDefClass.transform (/terser/dist/bundle.min.js:1:79151)
at /terser/dist/bundle.min.js:1:82505
at AST_ClassExpression.transform (/terser/dist/bundle.min.js:1:79182)
at /terser/dist/bundle.min.js:1:82415
at AST_ObjectSetter.transform (/terser/dist/bundle.min.js:1:79182)
at /terser/dist/bundle.min.js:1:79313
at l (/terser/dist/bundle.min.js:1:931)
at e (/terser/dist/bundle.min.js:1:1251)
at Mn (/terser/dist/bundle.min.js:1:79287)
Expected result
node test/fuzz.js should run forever.
Minimal repro:
maximum-callstack-size-exceeded.js:
class a {
set() {
class b {
set [b] (c) {}
}
}
}
cat maximum-callstack-size-exceeded.js | bin/terser -c
ERROR: Maximum call stack size exceeded
at Function.[Symbol.hasInstance] (<anonymous>)
at Tn.self [as before] (/terser/lib/compress/index.js:4125:22)
at AST_ClassExpression.transform (/terser/lib/transform.js:94:20)
at properties (/terser/lib/transform.js:267:36)
at AST_ObjectSetter.transform (/terser/lib/transform.js:98:9)
at tw (/terser/lib/transform.js:106:9)
at l (/terser/lib/utils/index.js:90:11)
at i (/terser/lib/utils/index.js:115:38)
at in_list (/terser/lib/transform.js:102:57)
at tw (/terser/lib/transform.js:278:52)
Fine with 2889744e409fa919abae195d00da926f51e980fb reverted.
Awesome, thanks for this report!
I'm seeing the same behavior when upgrading my project to use 4.5.1
I haven't gotten to this yet since it seems a bit far fetched. @eamodio can you please provide a minimal reproduction? Would be good to know what other things can cause this bug.
Unfortunately I don't have a minimal repo, but it can be easily reproduced with GitLens.
develop branchyarnyarn upgrade -- which will update the version of Terser from 4.4.3 to 4.5.1yarn run bundle -- builds the project and will fail with the latest TerserHere is what I see when I run yarn run bundle:
yarn run bundle
yarn run v1.21.1
$ webpack --env.production
dist-web/index.js
Rewrote universal-user-agent's package.json module field to `dist-node/index.js`
Optimizing images (src/webviews/apps/images/settings/*.png)...
Starting type checking service...
Starting type checking service...
Child extension:
Time: 11280ms
Built at: 01/05/2020 5:55:01 PM
5 assets
ERROR in extension.js from Terser
RangeError: Maximum call stack size exceeded
at AST_Dot.transform (C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:79101)
at C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:82445
at AST_ObjectKeyVal.transform (C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:79182)
at C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:79313
at l (C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:931)
at e (C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:1251)
at Mn (C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:79287)
at C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:82338
at AST_Object.transform (C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:79182)
at C:\Users\Eric\code\eamodio\vscode-gitlens\node_modules\terser\dist\bundle.min.js:1:79313
Child webviews:
Time: 8161ms
Built at: 01/05/2020 5:54:58 PM
Asset Size Chunks Chunk Names
main-styles.css 22.6 KiB 0 [emitted] main-styles
main-styles.js 990 bytes 0 [emitted] main-styles
settings.html 104 KiB [emitted]
settings.js 24 KiB 1 [emitted] settings
welcome.html 38.6 KiB [emitted]
welcome.js 20.4 KiB 2 [emitted] welcome
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Of that repo, I ended up with a pretty simple reproduction:
class x {
constructor() {
x();
}
}
I've recorded a video of doing this, so it might help people come up with minimal reproducible issues.