Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Skip trailing comma in explicit partial application#6949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@shulhi
Copy link
Member

@shulhishulhiforce-pushed thefix-trailing-comma-in-partial-function-dotdotdot branch from9aa6b1a tob8428cfCompareAugust 13, 2024 08:11
in
Doc.concat [Doc.lparen; arg_doc;Doc.rparen]
|args ->
(* Avoid printing trailing comma when there is ... in function application*)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I don't think it matters whether to check if... happens at the end because that's already considered as syntax error.

zth reacted with thumbs up emoji
@zth
Copy link
Member

zth commentedAug 13, 2024

I think this looks good.@cristianoc any comments?

Copy link
Collaborator

@cristianoccristianoc left a comment

Choose a reason for hiding this comment

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

Would you add a syntax test case too, so we see it being exercised.
(FTR, those would fail before your failed test, so you can test them locally on any machine)

shulhi reacted with thumbs up emoji
Doc.concat [Doc.lparen; arg_doc;Doc.rparen]
|args ->
(* Avoid printing trailing comma when there is ... in function application*)
let hasDotDotDot, printed_args=
Copy link
Collaborator

Choose a reason for hiding this comment

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

would you do a little search if this functionality already exists somewhere else?
I kind of don't even remember using... verbatim as label, instead of some other attribute.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is what I see in the parser let attrs = if is_partial then [res_partial_attr] else [] in
so I'm not sure your code runs? In any case, adding a test will answer this.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

The label does not exist. In the ast.

shulhi reacted with thumbs up emoji
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think of it as app1(f, args) vs app2(f, args)

One being total and the other partial.
Internally the distinction is only the presence of the attribute.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So "..." only exists as string in the source, but that's not how it's represented in the AST.

if partialthen
let dummy=Ast_helper.Exp.constant (Ast_helper.Const.int0)in
let loc=
{Asttypes.txt="res.partial";Asttypes.loc= expr.pexp_loc}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

For the dummy attribute, I addedres.partial so it can be pattern matched with the attribute rather than the label.

Copy link
MemberAuthor

@shulhishulhiAug 13, 2024
edited
Loading

Choose a reason for hiding this comment

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

Looking at previous code, it doesn't look like the choice of theexpression here matters. It only cares about the label, so tagging partial attribute here allows us to pattern match on the attribute rather than the label.

@shulhishulhi marked this pull request as ready for reviewAugust 13, 2024 14:08
@cknitt
Copy link
Member

@shulhi Could you add a CHANGELOG entry?

@shulhi
Copy link
MemberAuthor

@shulhi Could you add a CHANGELOG entry?

Done. Should we also backport this to v11?

@cknittcknitt merged commit9a65856 intorescript-lang:masterAug 15, 2024
@cknitt
Copy link
Member

Done. Should we also backport this to v11?

Yes, I think so. I will do cherry picking to v11 in bulk at a later time.

@shulhishulhi deleted the fix-trailing-comma-in-partial-function-dotdotdot branchAugust 15, 2024 10:37
cknitt pushed a commit to cknitt/rescript that referenced this pull requestSep 8, 2024
* Check for dotdotdot in args* Check on attribute rather than label* Add tests* Fix naming convention* Update CHANGELOG
cknitt pushed a commit to cknitt/rescript that referenced this pull requestSep 8, 2024
* Check for dotdotdot in args* Check on attribute rather than label* Add tests* Fix naming convention* Update CHANGELOG
cknitt pushed a commit that referenced this pull requestSep 10, 2024
* Check for dotdotdot in args* Check on attribute rather than label* Add tests* Fix naming convention* Update CHANGELOG
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cknittcknittcknitt approved these changes

@cristianoccristianoccristianoc approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Formatter Breaks Explicit Partial Application Syntax When Split By a Line Break

4 participants

@shulhi@zth@cknitt@cristianoc

[8]ページ先頭

©2009-2025 Movatter.jp