Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Remove printing of arrow functions with "multiple" dots #668

Merged
merged 3 commits into from
Oct 3, 2022

Conversation

IwanKaramazow
Copy link
Contributor

Arrow functions with multiple dots (. a, . b) => a + b are considered an anti-pattern. This syntax will be removed in the future. As a first step, the printer will know print this as multiple arrow functions. (Like in JavaScript)

Before

let f = (. a, . b) => a + b
type f = (. int, . int) => int

After

let f = (. a) => (. b) => a + b
type f = (. int) => (. int) => int

Arrow functions with multiple dots `(. a, . b) => a + b` are considered an anti-pattern.
This syntax *will be removed* in the future. As a first step, the printer will know print this as multiple arrow functions. (Like in JavaScript)

**Before**
```rescript
let f = (. a, . b) => a + b
type f = (. int, . int) => int
```

**After**
```rescript
let f = (. a) => (. b) => a + b
type f = (. int) => (. int) => int
```
ptyp_desc = Ptyp_arrow ((Nolabel as lbl), typ1, typ2);
ptyp_attributes = [({txt = "bs" | "res.async"}, _)] as attrs;
ptyp_desc = Ptyp_arrow (Nolabel, _typ1, _typ2);
ptyp_attributes = [({txt = "bs" | "res.async"}, _)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add examples of nested async functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what that is doing here. type f = async (…) => … does not exist. Will remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in def9fa0

Type expressions can't use the "async" keyword.
@cristianoc
Copy link
Contributor

Would you add a line to the changelog and merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants