Skip to content

Parse labeled tuple patterns and types #1523

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2023

Conversation

rtjoa
Copy link
Contributor

@rtjoa rtjoa commented Jun 22, 2023

Summary

Parses labeled tuple patterns using the following temporary syntax. Note the use of punning, punning + annotations, and mixed labeled and non-labeled arguments. Labels are separated from their patterns with =, components are separated with ; (desired syntax: : and ,, respectively).

let ~~(~x=x0; ~s; ~(y:int); _) = ~~(~x: 1, ~s: "a", ~y: 2, "ignore me")

Parses labeled tuple types using the following temporary syntax:

val mytup : ~~(x:int * y:string * string)

Testing

Added testcases to ocaml/testsuite/tests/typing-labeled-tuples/labeledtuples.ml.

To test -dsource, added a testcase to ocaml/testsuite/tests/typing-labeled-tuples/labeledtuples_dsource.ml.

Added CR: labeled tuples throughout areas that will eventually need more thorough testing.

@rtjoa rtjoa changed the title Lt parse types and pats Parse labeled tuple patterns and types Jun 22, 2023
@rtjoa rtjoa marked this pull request as ready for review June 22, 2023 16:22
@rtjoa rtjoa requested a review from ccasin as a code owner June 22, 2023 16:22
@rtjoa rtjoa closed this Jun 22, 2023
@rtjoa rtjoa force-pushed the lt-parse-types-and-pats branch from 4010c19 to d7c82a9 Compare June 22, 2023 18:45
@rtjoa rtjoa reopened this Jun 22, 2023
@rtjoa rtjoa force-pushed the lt-parse-types-and-pats branch from 4010c19 to 18e55a5 Compare June 22, 2023 19:04
Copy link
Contributor

@ccasin ccasin left a comment

Choose a reason for hiding this comment

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

This looks good.

I have some minor comments, and I think this PR should probably also update core_type_desc, since you have working examples with labeled tuple type expressions - see the comment in typetexp.ml

@rtjoa rtjoa force-pushed the lt-parse-types-and-pats branch from a1821b1 to 6317bb5 Compare June 23, 2023 14:53
@rtjoa rtjoa force-pushed the lt-parse-types-and-pats branch from 6317bb5 to e848590 Compare June 23, 2023 15:01
Copy link
Contributor

@ccasin ccasin left a comment

Choose a reason for hiding this comment

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

This all looks good now, thanks! I pushed a commit that just regenerates the parser, since the last commit changed the mly, and I'll merge once the tests pass.

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

Successfully merging this pull request may close these issues.

2 participants