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

Error propagation expressions do not declare variables #3162

Open
CohenArthur opened this issue Sep 12, 2024 · 2 comments
Open

Error propagation expressions do not declare variables #3162

CohenArthur opened this issue Sep 12, 2024 · 2 comments

Comments

@CohenArthur
Copy link
Member

CohenArthur commented Sep 12, 2024

Reproducer

#[lang = "sized"]
trait Sized {}

enum Result<T, E> {
    Ok(T),
    Err(E)
}

fn foo() -> Result<i32, i32> {
    Result::Ok(15)
}

fn bar() -> Result<i32, i32> {
    let result = foo()?;

    Result::Ok(result)
}

godbolt link

@badumbatish
Copy link
Contributor

we must have forgot to visit the expr in rust-hir-type-check and resolve the wrapping? I'm trying to see how I can decide if it will be an Ok or an Err when we compile the code .... any guidance?

@philberty
Copy link
Member

I have a feeling that this will go away with some HIR desugar but we need to finish the for loop expression one first before it will make sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants