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

return/break/continue within loops #196

Closed
franziskuskiefer opened this issue Jul 7, 2023 · 3 comments
Closed

return/break/continue within loops #196

franziskuskiefer opened this issue Jul 7, 2023 · 3 comments
Assignees
Labels
engine Issue in the engine help wanted Extra attention is needed P1 Max priority unsupported-rust Rust code rejected by hax. Unless marked wontfix, we want to support it soon.

Comments

@franziskuskiefer
Copy link
Member

Some for loop issues

pub fn loop1() -> Result<u8, u8> {
    let p1 = vec![1, 2, 3];
    for i in 0..p1.len() {
        if p1[i] == 3 {
            return Ok(p1[i]);
        }
    }
    Err(1)
}

pub fn loop2() -> Result<u8, u8> {
    let p1 = vec![1, 2, 3];
    for _ in 0..p1.len() {
        continue;
    }
    Err(1)
}

produces

error[HAX0001]: CfIntoMonads:something is not implemented yet.This is discussed in issue https://github.com/hacspec/hacspec-v2/issues/96.
                Please upvote or comment this issue if you see this error message.
                TODO: Monad for loop-related control flow
  --> src/lib.rs:26:5
   |
26 | /     for _ in 0..p1.len() {
27 | |         continue;
28 | |     }
   | |_____^

error[HAX0001]: FunctionalizeLoops:something is not implemented yet.
                Loop without mutation?
  --> src/lib.rs:16:5
   |
16 | /     for i in 0..p1.len() {
17 | |         if p1[i] == 3 {
18 | |             return Ok(p1[i]);
19 | |         }
20 | |     }
   | |_____^

error[HAX0001]: FunctionalizeLoops:something is not implemented yet.
                Only for loop are being functionalized for now
  --> src/lib.rs:26:5
   |
26 | /     for _ in 0..p1.len() {
27 | |         continue;
28 | |     }
   | |_____^
@franziskuskiefer franziskuskiefer added the engine Issue in the engine label Jul 7, 2023
@franziskuskiefer franziskuskiefer added the help wanted Extra attention is needed label Aug 21, 2023
@franziskuskiefer
Copy link
Member Author

Also see #96

@franziskuskiefer franziskuskiefer moved this to Todo in hax Aug 21, 2023
@W95Psp W95Psp changed the title for loop issues Support return/break/continue within loops Jan 2, 2024
@W95Psp W95Psp added the P1 Max priority label Jan 2, 2024
@W95Psp W95Psp added the unsupported-rust Rust code rejected by hax. Unless marked wontfix, we want to support it soon. label Jan 5, 2024
@W95Psp W95Psp changed the title Support return/break/continue within loops return/break/continue within loops Jan 5, 2024
@W95Psp W95Psp mentioned this issue May 16, 2024
9 tasks
@W95Psp
Copy link
Collaborator

W95Psp commented Jun 10, 2024

Would be nice to have for ML-Kem

W95Psp added a commit to cryspen/sandwich that referenced this issue Jun 11, 2024
 - `let ... else {...}` is not supported yet (see cryspen/hax#155);
 - `return` inside a loop is not supported yet (see cryspen/hax#196).
W95Psp added a commit to cryspen/sandwich that referenced this issue Jun 11, 2024
 - `let ... else {...}` is not supported yet (see cryspen/hax#155);
 - `return` inside a loop is not supported yet (see cryspen/hax#196).
elenaf9 added a commit to elenaf9/RIOT-rs that referenced this issue Sep 23, 2024
Hax doesn't support early returns (see cryspen/hax#196) so we have to
iterate through the whole array.
@W95Psp
Copy link
Collaborator

W95Psp commented Sep 30, 2024

Closing in favor of #196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Issue in the engine help wanted Extra attention is needed P1 Max priority unsupported-rust Rust code rejected by hax. Unless marked wontfix, we want to support it soon.
Projects
None yet
Development

No branches or pull requests

3 participants