Skip to content

cmd/compile: compiler does vet things #54019

Closed as not planned
Closed as not planned
@zigo101

Description

@zigo101

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

$ go version
go version go1.19rc2 linux/amd64

Also for many previous versions.

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

func main() {}

func foo() (err error) {
	{
		err := bar()
		if err != nil {
			return
		}
	}
	
	return
}

func bar() error {
	return nil
}

What did you expect to see?

Complies okay.

What did you see instead?

Fails to compile.

$ go run main.go
# command-line-arguments
./main.go:9:4: result parameter err not in scope at return
	./main.go:7:3: inner declaration of var err error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions