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

Compiler optimizing while True loop away #532

Closed
lsh opened this issue Aug 28, 2023 · 2 comments
Closed

Compiler optimizing while True loop away #532

lsh opened this issue Aug 28, 2023 · 2 comments
Assignees
Labels
bug Something isn't working mojo Issues that are related to mojo

Comments

@lsh
Copy link
Contributor

lsh commented Aug 28, 2023

Bug description

The following code will result in no output with mojo file.mojo

Steps to reproduce

Run mojo file.mojo where the file contains:

fn main():
    var i = 0
    while True:
        for j in range(i):
            print_no_newline(j, " ")
        print()
        if i > 10:
            break
        i += 1

System information

Ubuntu 22.04 in a devcontainer on an Intel MacBook pro.
@lsh lsh added the bug Something isn't working label Aug 28, 2023
@abduld
Copy link
Contributor

abduld commented Aug 28, 2023

Also

fn main():
    var i = 0
    while i < 10:
        for j in range(i):
            print_no_newline(j, " ")
        print()
        i += 1

prints a few new lines but does not print the value of j

This

fn main():
    for i in range(10):
        for j in range(i):
            print_no_newline(j, " ")
        print()

works fine though

@weiweichen weiweichen self-assigned this Sep 5, 2023
@ematejska ematejska added the mojo Issues that are related to mojo label Sep 7, 2023
@weiweichen
Copy link
Contributor

Reopen to wait for another PR to merge.

@weiweichen weiweichen reopened this Sep 8, 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
Projects
None yet
Development

No branches or pull requests

4 participants