decaffeinate crashes with a thin arrow function in an object
See original GitHub issuedecaffeinate is crashing on my CoffeeScript input:
# Bad
prop: (x) -> x
# OK
#prop: (x) => x
# Also OK
#func((x) -> x)
if Babel is configured to target fairly old browsers as follows:
// babel.config.js
module.exports = {
presets: [
// Bad
["@babel/preset-env", { targets: ["IE 11"] }],
// OK
//["@babel/preset-env", { targets: ["last 1 Chrome version"] }],
],
};
Minimal reproducible setup is here https://gitlab.com/uasi/20191112-decaffeinate-crash
I get this error:
/Users/uasi/tmp/decaf/node_modules/decaffeinate/dist/cli.js:304
throw err;
^
RangeError: unknown: Maximum call stack size exceeded
at Object.get [as isBlockScoped] (/Users/uasi/tmp/decaf/node_modules/@babel/types/lib/index.js:286:17)
at Object.checkPath (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/lib/virtual-types.js:118:14)
at Object.newFn (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/visitors.js:215:17)
at NodePath._call (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:38:14)
at NodePath.visit (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:90:31)
at TraversalContext.visitQueue (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitSingle (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:84:19)
at TraversalContext.visit (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:140:19)
at Function.traverse.node (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/index.js:84:17)
at NodePath.visit (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:97:18)
at TraversalContext.visitQueue (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitMultiple (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:79:17)
at TraversalContext.visit (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:138:19)
at Function.traverse.node (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/index.js:84:17)
at NodePath.visit (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:97:18)
at TraversalContext.visitQueue (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitSingle (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:84:19)
at TraversalContext.visit (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:140:19)
at Function.traverse.node (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/index.js:84:17)
at traverse (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/index.js:66:12)
at NodePath.traverse (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/index.js:148:24)
at Scope.crawl (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/scope/index.js:639:10)
at Scope.init (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/scope/index.js:589:32)
at NodePath.setScope (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:131:30)
at NodePath.replaceWith (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/replacement.js:159:8)
at PluginPass.ObjectProperty (/Users/uasi/tmp/decaf/node_modules/@resugar/codemod-objects-concise/src/index.js:20:22)
at newFn (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/visitors.js:179:21)
at NodePath._call (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:42:17)
at NodePath.visit (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/path/context.js:90:31)
at TraversalContext.visitQueue (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitQueue (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:118:21)
at TraversalContext.visitQueue (/Users/uasi/tmp/decaf/node_modules/@babel/traverse/lib/context.js:118:21)
...
Issue Analytics
- State:
- Created 4 years ago
- Comments:13
Top Results From Across the Web
Why extending property of existing object with arrow function ...
Why arrow function fails to identify this pointer in the following case. I know that regular functions have their own execution scope and ......
Read more >Crash when using arrow functions in {@const} #7134 - GitHub
Describe the bug When creating a markup variable with {@const}, whose value uses an arrow function in some way (for example, finding an...
Read more >When You Should Not Use The Arrow Functions
In this tutorial, you will learn when you should not use the arrow functions in ES6 including event handlers, methods of objects, classes,...
Read more >Arrow Functions In Javascript - Medium
Arrow Functions — also called “fat arrow” functions, are relatively a new way of writing concise functions in JavaScript. They have been introduced...
Read more >Arrow Functions JavaScript Tutorial - What NOT to do!!!
What are arrow functions in JavaScript? How do you write them? When should you use them? When should you NOT use them?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🎉 This issue has been resolved in version 6.1.9 🎉
The release is available on:
Your semantic-release bot 📦🚀
I think I found the root cause.
We can reproduce this bug only using the
@babel/plugin-transform-shorthand-properties
plugin, which is a part of@babel/preset-env
.It transforms concise methods to longer form (
{ func() {...} }
->{ func: function() {...} }
), while the@resugar/codemod-objects-concise
plugin used by decaffeinate does the opposite.Maybe these plugins rewrite each other’s output endlessly.