Skip to content
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

Typecheck labeled tuple terms #1502

Merged
merged 5 commits into from
Jun 22, 2023

Conversation

rtjoa
Copy link
Contributor

@rtjoa rtjoa commented Jun 15, 2023

Summary

  • Typecheck labeled tuple terms, e.g. ~~(~x: 1, "hi") as x: int * string
  • Ensures tuple types match when unifying
  • Implementation: adds a string option * to the element types of Texp_tuple's and TTuples's lists

Testing

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

Printtyp.raw_type_expr was tested via the debugger.

The type of the value ~~(~lbl:5, "hi") prints as:

Ttuple
        [label="lbl" {id=114;level=100000000;scope=0;desc=Tconstr(int,[],[])};
         {id=115;level=100000000;scope=0;desc=Tconstr(string,[],[])}]};

@rtjoa rtjoa force-pushed the lt-type-terms-merged branch from 6cc8c3c to ec00b16 Compare June 20, 2023 15:32
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 a bunch of minor suggestions, but didn't spot any big issues.

ocaml/lambda/translcore.ml Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Show resolved Hide resolved
ocaml/lambda/translcore.ml Show resolved Hide resolved
ocaml/lambda/translcore.ml Show resolved Hide resolved
ocaml/typing/typecore.ml Show resolved Hide resolved
ocaml/typing/typedecl.ml Outdated Show resolved Hide resolved
ocaml/typing/typedecl_variance.ml Outdated Show resolved Hide resolved
ocaml/typing/typedecl_variance.ml Show resolved Hide resolved
ocaml/typing/typeopt.ml Outdated Show resolved Hide resolved
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.

3 participants