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

[BUG]: Mojo hangs if you use continue in the nested loop #943

Closed
zverianskii opened this issue Sep 28, 2023 · 2 comments
Closed

[BUG]: Mojo hangs if you use continue in the nested loop #943

zverianskii opened this issue Sep 28, 2023 · 2 comments
Assignees
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-lang Tag for all issues related to language.

Comments

@zverianskii
Copy link
Contributor

Bug description

Minimum example:

fn main():
    for i in range(4):
        for j in range(4):
            print(i,j)            
        else:
            continue

This pattern is typical if you try to exit nested loop in python:

fn main():
    for i in range(4):
        for j in range(4):
            print(i,j)
            if (i == 2) and (j==2):
                break
        else:
            continue
        break

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

System information

- What OS did you do install Mojo on ? Ubuntu 23
- Provide version information for Mojo by pasting the output of `mojo -v` mojo 0.3.0 (f64f9601)
- Provide Modular CLI version by pasting the output of `modular -v` modular 0.1.4 (6b54d308)
@zverianskii zverianskii added bug Something isn't working mojo Issues that are related to mojo labels Sep 28, 2023
@ematejska ematejska added the mojo-lang Tag for all issues related to language. label Sep 28, 2023
@Mogball
Copy link
Collaborator

Mogball commented Sep 28, 2023

@weiweichen could you take a look?

@Mogball
Copy link
Collaborator

Mogball commented Sep 28, 2023

@lispsil Thanks for filing! From a glance, it seems like the behaviour of for ... else is not implemented correctly, causing the else block to always get executed.

@weiweichen weiweichen self-assigned this Sep 28, 2023
@modularml modularml deleted a comment from weiweichen Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-lang Tag for all issues related to language.
Projects
None yet
Development

No branches or pull requests

4 participants