Skip to content

Short variable declarations without new variables compile pass #5140

@gopherbot

Description

@gopherbot

by zhengbaiqiang:

package main

func main() {
    i, j := 1, 2
    {
        i = 10
        j = 11
        i, j := 3, 4
        println(i, j)
    }
    println(i, j)
}

What is the expected output?
expect "i, j := 3, 4" compile error, because there are no new variables on
left side of :=.

What do you see instead?
compile pass, print:
3 4
10 11

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
Windows

Which version are you using?  (run 'go version')
go 1.0.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions