Skip to content

cmd/compile: compiler error for valid code #75069

@Jorropo

Description

@Jorropo

reported by @ivanjaros in #72860 (comment)

I just updated my Go version to 1.25 and I immediately got compilation error for the following code - which is correct and should compile, but this new change makes it fail:

func RetrieveOauthCodeGrantHandler(ctx context.Context, req RetrieveOauthCodeGrantRequest) (res *RetrieveOauthCodeGrantResponse, err error) {
	errOut := func(errType, info string) {
		res = &RetrieveOauthCodeGrantResponse{
			Failure: &RetrieveOauthCodeGrantResponse_Failure{
				Error:            errType,
				ErrorDescription: info,
				ErrorURI:         "",
			},
		}
		err = nil
	}

	if err := req.Validate(); err != nil {
		errOut("invalid_request", errors.String(err))
		return
	}

	...
}

I had to rename the variable to e:

	if e := req.Validate(); e != nil {
		errOut("invalid_request", errors.String(e))
		return
	}

I think this change has not been implemented correctly if this is not compiling. I usually don't write my code like this but this is a special case where it had to be done like this and i caught it right away by accident(as I usually don't write code like this).

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions