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

Fix eaten async for function with labelled args #676

Closed
wants to merge 2 commits into from

Conversation

mununki
Copy link
Member

@mununki mununki commented Oct 13, 2022

This PR fixes #674

@mununki mununki changed the title Fix eaten async Fix eaten async for function with labelled args Oct 13, 2022
@mununki
Copy link
Member Author

mununki commented Oct 13, 2022

I don't know the history of why letting only the pexp_fun with nolabel arg keeps the attributes.

pexp_desc = Pexp_fun (Nolabel, _defaultExpr, _pattern, _returnExpr);

@mununki
Copy link
Member Author

mununki commented Oct 13, 2022

This PR allows the Pexp_fun with labeled and optional to keep the res.async attribute only.

@mununki mununki requested review from cknitt and cristianoc October 13, 2022 15:40
Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks a lot for fixing this! 🎉

(I don't know why Pexp_fun with Nolabel keeps all attributes either though.)

@cristianoc
Copy link
Contributor

Oops, I had another fix done on the plane:
#677

@cristianoc
Copy link
Contributor

Basically, for (@foo ~a) => ... when one wants to put an attribute on the label, there's no way to represent this directly in the AST, as labelled args don't have attributes.
So the convention is to take the attributes on the function, and consider them applied to the label.

This does not fit well with the fact that async is put on the function, and some adjustment is needed.

(fun (({txt}, _) : Parsetree.attribute) -> txt = "res.async")
attrs
in
collect asyncAttr [] {expr with pexp_attributes = []}
Copy link
Contributor

Choose a reason for hiding this comment

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

This throws away all the other attributes, if there are some.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct.

@mununki
Copy link
Member Author

mununki commented Oct 13, 2022

Basically, for (@foo ~a) => ... when one wants to put an attribute on the label, there's no way to represent this directly in the AST, as labelled args don't have attributes.
So the convention is to take the attributes on the function, and consider them applied to the label.

This does not fit well with the fact that async is put on the function, and some adjustment is needed.

There was a reason! Thank you for the explanation. I couldn't guess it. 👍

@mununki
Copy link
Member Author

mununki commented Oct 13, 2022

I'm going to close this PR, #677 will fix the issue.

@mununki mununki closed this Oct 13, 2022
@mununki mununki deleted the fix-eaten-async branch October 13, 2022 23:49
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.

async gets formatted away for functions with labeled arguments
3 participants