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

fix: preceding simple statement in IfStmt should have its own block #35

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

shenyih0ng
Copy link
Owner

@shenyih0ng shenyih0ng commented Apr 16, 2024

Description

Right now the ECE fails the following test case:

func main() {
    var i = 26
    
    if i := 25; i % 3 == 0 && i % 5 == 0 {
        println("FizzBuzz")
    } else if i % 3 == 0 {
        println("Fizz")
    } else if i % 5 == 0 {
        println(i) // 25 
        println("Buzz") // Buzz
    }
    
    println(i) // 26
}

This is because the declaration i:=25 incorrectly reassigns the i in the scope of main. The fix is to surround the if statement with a block if there is a preceding statement

@shenyih0ng shenyih0ng self-assigned this Apr 16, 2024
@shenyih0ng shenyih0ng merged commit 3134686 into master Apr 16, 2024
1 check passed
@shenyih0ng shenyih0ng deleted the fix/if-simple-stmt branch April 17, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant