`function(a) {};` changed into `(function(a) {})` even when AST does not change
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 363
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
The following test case
```
import assert from "assert";
import * as recast from "recast";
import {EOL as eol} from "os";
it("should keep unmodified function as is", function () {
const code = ["const a = b => function(a) {};"].join(eol);
const ast = recast.parse(code);
assert.strictEqual(
recast.print(ast).code,
["const a = b => function(a) {};"].join(eol),
);
});
```
produces
```
Expected value to strictly be equal to:
"const a = b => function(a) {};"
Received:
"const a = b => (function(a) {});"
```
for me. From what I understand, recast does not change unmodified code - is this a special case where it's different, or a legit bug?
Contributor guide
No contributing guide indexed for this repository
Research direction
Use the provided test case as a regression test and trace the recast.parse and recast.print entry points for this function expression. The issue is done when printing the unchanged AST preserves `function(a) {};` rather than adding parentheses, and the regression test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100