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

Fatal error in side_effect_utils.ml #1175

Open
franziskuskiefer opened this issue Dec 9, 2024 · 1 comment
Open

Fatal error in side_effect_utils.ml #1175

franziskuskiefer opened this issue Dec 9, 2024 · 1 comment

Comments

@franziskuskiefer
Copy link
Member

franziskuskiefer commented Dec 9, 2024

The following code fails to extract to F*.

enum A{
    X
}
enum B{
    X
}
trait Rng {}

fn other_fun<R: Rng>(rng: &mut R) -> Result<(A, B), u8> {
    Ok((A::X, B::X))
}

fn fun<R: Rng>(x: u8, rng: &mut R) -> Result<(A, B), u8> {
    return Ok((A::X, other_fun(rng)?.1));
}

Open this code snippet in the playground

This can be worked around with the following

fn fun<R: Rng>(x: u8, rng: &mut R) -> Result<(A, B), u8> {
    let tmp = other_fun(rng)?;
    return Ok((A::X, tmp.1));
}
@maximebuyse maximebuyse self-assigned this Dec 11, 2024
@maximebuyse
Copy link
Contributor

I quickly investigated. The reproducer can be minimized to the following:

fn other_fun(rng: &mut i8) -> Result<(), ()> {
    Ok(())
}

fn fun(rng: &mut i8) -> Result<(), ()> {
    return Ok(other_fun(rng)?);
}

Open this code snippet in the playground

I used a modified hax version to pretty-print the expected types in the error, which gives:
Expected two exact same types, got x=core::result::t_Result<tuple0, tuple0> and y=tuple2<int, core::result::t_Result<tuple0, tuple0>>

So it seems like there is a conflict between hoisting the ? side effect and hoisting the function call that should return the value of its &mut parameter.

@maximebuyse maximebuyse removed their assignment Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants