-
Notifications
You must be signed in to change notification settings - Fork 89
Typing for parameterised libraries #1726
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
Conversation
This is a big PR! What’s the review plan here? Maybe this question is premature (feel free to tell me to look away), but I’m curious if any other type-systems person has this on their radar… |
Step one is certainly for me to split it up. (I just did a bit of that with #1746, which turns out to be largely orthogonal.) I had things nicely split into a stack of branches, but everything's so interrelated that it got impractical to keep them split up, but now that things are actually working I feel a bit more confident drawing lines around things. (That said, it's annoyingly possible that instantiation will require yet more changes to this code. But at least I can write meaningful tests against this PR, which is more than I can say for, say, just the syntax extension.) |
d31f18f
to
2eb7bbf
Compare
Displaying the correct error message will be easier again after ocaml-flambda#1764
This reverts commit 6f86fb9.
This both makes `test.ml` _far_ easier to maintain and will also make testing native compilation easy without copying everything. Pulled from the 'instantiate' branch, commit fab77b5.
Pulled from the 'instantiate' branch, commit 454de0d.
Pulled from 'instantiate' branch, commit a9f9196.
Punted on conflicts in `test.ml` since we're switching to generating it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some preliminary comments on the tests.
ocaml/testsuite/tests/templates/basic/bad_instance_arg_name_not_found.reference
Outdated
Show resolved
Hide resolved
ocaml/testsuite/tests/templates/basic/bad_instance_arg_value_not_arg.reference
Outdated
Show resolved
Hide resolved
ocaml/testsuite/tests/templates/basic/bad_instance_arg_value_not_found.reference
Outdated
Show resolved
Hide resolved
ocaml/testsuite/tests/templates/basic/bad_instance_arg_value_wrong_type.reference
Outdated
Show resolved
Hide resolved
ocaml/testsuite/tests/templates/basic/bad_ref_direct_imported.reference
Outdated
Show resolved
Hide resolved
Previously this was pretty rare (only one existing test needed to be promoted), with the exception of `Not_found` which has special handling, but parameterised modules add new and interesting ways for the user to mess up, and we want those errors to have location information (which `Persistent_env` functions aren't aware of).
Also exercises a couple of new cases: passing the same name as `-parameter` and `-as-argument-for` (i.e., implementing operators over parameter modules), and having a parameter module just include an `_intf.S`. (The latter isn't technically difficult but I expect it to be an important use case.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you - my first round of review is finished.
Admittedly I didn't look carefully at utils/symbol.ml
.
Currently the mode should always be `legacy` but this wasn't being checked. Also quit passing `path` around in a few places where we know full well the path is just a single global identifier.
ocaml/testsuite/tests/templates/basic/bad_instance_arg_value_wrong_type.reference
Outdated
Show resolved
Hide resolved
ocaml/testsuite/tests/templates/basic/bad_instance_arg_value_not_arg.reference
Outdated
Show resolved
Hide resolved
ocaml/testsuite/tests/templates/basic/bad_param_not_param.reference
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to go.
A gentle reminder that maybe we want to move some changes from the next PR to the current PR:
#1905 (comment)
#1905 (comment)
I have no strong opinion - maybe it's not worthwhile.
Typechecking of references to parameterised libraries, with or without arguments. Currently such references can't actually be compiled to working code because we don't have the
-instantiate
pass, but this contains all the typechecking logic to make sure that, for instance, a moduleA
can't refer to a parameterised moduleB
unlessA
takes all the parameters thatB
does (the subset rule) or the reference includes an argument for each missing parameter.