-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
let-rec wellformedness check too permissive with nested recursive bindings #7231
Comments
Comment author: @stedolan This seems like a thorny issue. How does the patch handle the following?
Note that in this example, the right-hand sides of each equation are more sensible, since no value is eliminated during its definition (the suspicious 'y ()' from the original test case has been removed). (The polymorphic variant `A is used to allow recursive types, you can also try this example using plain variants and -rectypes.) |
Comment author: @yallop Indeed, that example looks innocuous. Why does it crash? I'd like let rec r = (let rec x = `A r and y = fun () -> x in y) to be equivalent to let rec r = (let rec y = fun () -> `A r in y) to be equivalent to let rec r = (fun () -> `A r) but it's obviously not the case. |
Comment author: @garrigue My understanding is that r may only occur inside a definition in the same mutually recursive block, as they are represented as a single block containing multiple closures and values. I.e. |
Comment author: @lpw25 Duplicating my response on caml-devel about Stephen's second example: I don't think that the problem with this example is with the check but Indeed, the patch below is enough to compile the example successfully diff --git a/asmcomp/cmmgen.ml b/asmcomp/cmmgen.ml
|
Comment author: @stedolan Note that OCaml does in fact reject:
The crashing case is:
Inlining the let recs, we get:
which is rejected (the It is in principle possible to compile "aliases" as part of a let rec, as long as all uses of the aliases are correctly guarded. However, the current back end does not compile these correctly, and the current type checker does not detect all aliases. Fixing either would suffice to fix my example. I would mildly prefer fixing the back end and allowing aliases in the type checker if guarded (I find |
Comment author: @mshinwell |
Comment author: @yallop This is fixed in 4.06, now that GPR 556 is merged: let rec r = let rec x () = r and y () = x () in y () in r "oops";;Characters 58-64: |
Original bug ID: 7231
Reporter: @yallop
Assigned to: @yallop
Status: resolved (set by @yallop on 2017-09-25T14:11:51Z)
Resolution: fixed
Priority: normal
Severity: crash
Target version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Related to: #6738 #7215 #7447
Monitored by: runhang @stedolan @gasche
Bug description
$ ocaml
OCaml version 4.03.0+beta2
let rec r = let rec x () = r and y () = x () in y () in r "oops";;
Characters 58-64:
let rec r = let rec x () = r and y () = x () in y () in r "oops";;
^^^^^^
Warning 20: this argument will not be used by the function.
Segmentation fault
This should be fixed by the fix for PR6738 (and PR7215), which is now almost complete.
The text was updated successfully, but these errors were encountered: