Originally reported by @ehoogeveen in https://github.com/babel/babel/issues/12383#issuecomment-732140757. I managed to create a way smaller example which reproduces the bug.
I'm opening a new issue because I believe it's not related to #12383.
Current behavior
RangeError: /home/nicolo/Documenti/dev/babel-bugs/issue-12383/d3.js: Maximum call stack size exceeded
at NodePath.get (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/family.js:181:13)
at NodePath._resolve (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/introspection.js:316:14)
at NodePath.resolve (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/introspection.js:307:15)
at /home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js:72:27
at Array.filter (<anonymous>)
at getConstantViolationsBefore (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js:71:21)
at getTypeAnnotationBindingConstantViolations (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js:36:28)
at NodePath._default (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js:22:14)
at NodePath._getTypeAnnotation (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/inference/index.js:59:20)
at NodePath.getTypeAnnotation (/home/nicolo/Documenti/dev/babel-bugs/issue-12383/node_modules/@babel/traverse/lib/path/inference/index.js:23:19) {
code: 'BABEL_TRANSFORM_ERROR'
}
Input Code
function test() {
var b, c;
do {
c = 1;
b = c;
} while (false);
c = b;
c !== b;
}
Expected behavior
It shouldn't crash
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
babel.config.json{
"plugins": [
"babel-plugin-transform-simplify-comparison-operators"
]
}
Environment
cli, register, loader]Possible Solution
Additional context
A smaller example, not relying on babel-minify:
const code = `
var b, c;
if (0) {
c = 1;
b = c;
}
c = b;
`
const out = babel.transformSync(code, {
configFile: false,
plugins: [
(babel) => ({
visitor: {
Program(path) {
const assign = path.get("body.2.expression");
console.log(assign.toString()); // c = b;
console.log(assign.getTypeAnnotation())
}
}
})
]
});
^ This also reproduces the bug with Babel 7.12.0, so again it's a bug that was already present but that now is more common.
Most helpful comment
A smaller example, not relying on
babel-minify:^ This also reproduces the bug with Babel 7.12.0, so again it's a bug that was already present but that now is more common.