Skip to content

nested for loops in global scope can't share a control variable #493

Description

@egranata

This test program fails:

import aria.range.int_extension;

val inner = 0;
val outer = 0;
for i in 0.to(12) {
    for i in 0.to(500) {
        inner += 1;
    }
    outer += 1;
}

assert inner == 6000;
assert outer == 12;

because it only goes through the outer loop once, it sees i == 500 at the end of the first iteration and gets out

The program behaves correctly if embedded in a func main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Aria 1.5 Roadmapbreaking changeCan make existing code behave differentlybugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions