-
Notifications
You must be signed in to change notification settings - Fork 22
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
Engine: F*: Missing rec
qualifier in a mutually recursive top-level let
#1158
Comments
Here is a simple reproducer: mod a {
pub trait A{
fn f(&self);
}
impl A for i32 {
fn f(&self){
g(*self)
}
}
pub fn g(x: i32) {super::b::h(x)}
}
mod b {
pub fn h(x: impl super::a::A){x.f()}
} Open this code snippet in the playground This happens because the trait impl is considered to be part of the item-wise bundle. We should force item-wise bundles to contain either only functions or only types. |
This is actually tricky. We can minimize further to: pub trait A{
fn f(&self);
}
impl A for i32 {
fn f(&self){
g(*self)
}
}
pub fn g(x: i32) {x.f()} Open this code snippet in the playground
Here there is a mutual recursion between a method from a trait impl, and a top-level function. At the item level we have a cyclic dependency between I think the only way to solve this would be to hoist the method outside the impl. That can at least give a workaround (hoisting manually). |
After more investigation the reproducer is for a different problem. We should investigate more, there could be a bug in how we compute the dependency graph. |
Here is a reproducer: #1186. This is linked to naming (clash of names with bundling). |
trait T { fn f(); }
pub mod a {
impl super::T for u8{ fn f(){g()}}
pub fn g(){super::b::g()}
}
pub mod b {
impl super::T for i8 { fn f(){}}
pub fn g(){super::a::g()}
} |
Here is another interesting reproducer without bundles: fn f () {g()}
fn f_2(){f()}
fn g () {f()} Open this code snippet in the playground The problem is that mutual recursion is treated by inserting a |
I tried using #1140 which doesn't fix the problem. We probably need to add some dependencies in the dependency graph to treat a set of mutually recursive items as atomic. |
I believe this comes from a bug in ocamlgraph. I opened backtracking/ocamlgraph#149 |
I implemented a simple fix to ocamlgraph so if we don't get an answer quickly we have something we can use in a fork. Actually it might be a good thing not to rely on a standard implementation for this (except if we know what it does), because if you think of a graph like a <->c b <->d and want a stable topological sort with lexical order, then a, b, c, d could be considered the best answer but in our case we want elements that belong to the same cycle grouped together. My fork would behave well (for us) with respect to this but let's see if whatever solution that gets into ocamlgraph has this property. |
In some situations (likely connected to mutual bundles), mutual recursive functions get translated to
let ... and ...
bundles, but without therec
.We need a reproducer here.
The text was updated successfully, but these errors were encountered: