Skip to content

cmd/compile: package-level variable initialization order looks not correct #66585

@zigo101

Description

@zigo101

Go version

go version go1.22.1 linux/amd64

Output of go env in your module/workspace:

.

What did you do?

package main

var x = 0
var a = foo()
var b = x

func foo() int {
	x++
	return x
}

func main() {
	println(a, b) // 1 0
}

What did you see happen?

1 0

What did you expect to see?

1 1

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions