Fix Mantis PR#7767: interaction between labels and let rec check#1712
Fix Mantis PR#7767: interaction between labels and let rec check#1712gasche merged 3 commits intoocaml:trunkfrom
Conversation
| when is_ref vd -> Static | ||
| | Texp_apply (_,args) | ||
| when List.exists (function (_,None) -> true | _ -> false) args -> | ||
| Static |
There was a problem hiding this comment.
To someone reading the code without the full typedtree structure in mind, it is very unclear what this case is about (is_ref above is self-explanatory). Maybe you could avoid the when here, have a single (non-ref) Texp_apply case, and have on the test a comment explaining what the test is about? (Or you could make the test an auxiliary function with a self-explanatory name.)
There was a problem hiding this comment.
Or you could make the test an auxiliary function with a self-explanatory name.
I picked this option, so that the named function could be reused in the two locations where it's needed.
typing/typecore.ml
Outdated
| (* an expression abstracted over a missing argument *) | ||
| let arg env (_, eo) = option expression env eo in | ||
| let ty = Use.join (list arg env args) (expression env e) in | ||
| Use.(join (discard ty) (delay ty)) |
There was a problem hiding this comment.
I don't remember the details well, but isn't join (discard ty) (delay ty) equal to delay ty?
I think it could be nice if you merged the two cases. If it is the case that inspect (join a b) is equal to join (inspect a) (inspect b), you could write a single logic, with a test that applies either a delay or an inspect depending on whether the application is delayed by a missing argument.
There was a problem hiding this comment.
isn't
join (discard ty) (delay ty)equal todelay ty?
It's equal to discard ty, I think.
Thanks for the suggestions. I've merged the two cases, and added a comment.
There was a problem hiding this comment.
I checked and indeed discard, which is an alias for guard, is less permissive than delay, so their union is discard. This is still a bit non-intuitive to me, but I guess that in a call-by-value setting it is natural that evaluating now (and then not using) demands more than evaluating later.
This is the rebase of GPR #1712.
|
Merged in 4.07 by 92a0f54. |
Co-authored-by: Christine Rose <[email protected]> Co-authored-by: Thibaut Mattio <[email protected]>
A partially-applied labeled function, like this:
is translated into code that builds a function value, like this:
Consequently, the
let reccheck used to accept definitions whose rhss were partial applications of this form (Mantis PR 7767).This PR adds a case for partially-applied labeled functions to the new
let reccheck, to restore the old behaviour.