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

Single-statement for loop causes panic #182

Open
jlapeyre opened this issue Mar 20, 2024 · 0 comments
Open

Single-statement for loop causes panic #182

jlapeyre opened this issue Mar 20, 2024 · 0 comments
Labels
bug Something isn't working Looking for assignee Looking to contribute? Browse these.

Comments

@jlapeyre
Copy link
Collaborator

jlapeyre commented Mar 20, 2024

Version 0.4.0

These methods look for either a single statement or a body. If the body is not found, it should return None.

pub fn body(&self) -> Option<BlockExpr> {
support::child(&self.syntax)
}
pub fn stmt(&self) -> Option<Stmt> {
support::child(&self.syntax)
}

But when constructing the ASG, the final representation of the OQ3 program, we erroneously assume that the for statement loops over a block and never over a single statement:

let loop_body = from_block_expr(for_stmt.body().unwrap(), context);

In case there is no block, the unwrap causes a panic.

@jlapeyre jlapeyre added bug Something isn't working Looking for assignee Looking to contribute? Browse these. labels Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Looking for assignee Looking to contribute? Browse these.
Projects
None yet
Development

No branches or pull requests

1 participant