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] Unused iterator in for loop #11427

Open
aalok-t opened this issue Dec 19, 2023 · 4 comments
Open

[Bug] Unused iterator in for loop #11427

aalok-t opened this issue Dec 19, 2023 · 4 comments
Labels
bug Something isn't working stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@aalok-t
Copy link
Contributor

aalok-t commented Dec 19, 2023

🐛 Bug

We require the user to explicitly use an iterator even when it is not used in the loop body.

To reproduce

Consider the test:

script {
    fun main(): () {
        for (_ in 0..10) {};
    }
}

This raises an error Invalid variable usage. Unbound variable '_'.

Expected Behavior

This should instead be supported by the for loop as done in Rust.

@aalok-t aalok-t added the bug Something isn't working label Dec 19, 2023
@brmataptos
Copy link
Contributor

Can you provide a more complete example test case?

@aalok-t aalok-t self-assigned this Dec 20, 2023
@lbmeiyi lbmeiyi added the stale-exempt Prevents issues from being automatically marked and closed as stale label Jan 8, 2024
@wrwg
Copy link
Contributor

wrwg commented Jan 9, 2024

What is the status of this bug @aalok-t ?

@wrwg wrwg moved this from 🆕 New to 🏗 In progress in Move Language and Runtime Jan 9, 2024
@aalok-t
Copy link
Contributor Author

aalok-t commented Jan 9, 2024

What is the status of this bug @aalok-t ?

WIP. The PR for issue 11426 will also address it, by create a separate token for For.

brmataptos added a commit that referenced this issue Jan 10, 2024
@brmataptos
Copy link
Contributor

I just added a test to #11584 which shows the current errors for V1 and V2.

brmataptos added a commit that referenced this issue Jan 17, 2024
brmataptos added a commit that referenced this issue Jan 18, 2024
brmataptos added a commit that referenced this issue Jan 18, 2024
* add some tests for for loops
* fix missing output case
* get rid of tabs, commented tests, remove infinite_lop_with_dead_exits from -v2/tests since output is incorrect
* add tests illustrating issue #11427
@vineethk vineethk moved this from 🏗 In progress to For Grabs in Move Language and Runtime Feb 29, 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 stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: For Grabs
Development

No branches or pull requests

4 participants