Skip to content

spec: order of evaluation of variables in return statement is not determined #25609

Closed
@zboya

Description

@zboya

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version
go version go1.10.2 darwin/amd64

What did you do?

package main

import "fmt"

func main() {
	m, i, j := testChange()
	fmt.Println("retun ", m, i, j)
}

func testChange() (int, interface{}, int) {
	m := 0
	i := 0

	f := func() int {
		m = 2
		i = 2
		return 99
	}

	return m, i, f()
}

What did you expect to see?

retun 2 2 99

What did you see instead?

retun 2 0 99

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions