Skip to content

reflect: Set: argument validation panics with ValueError, which is for receiver #41953

Description

@tcard

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

$ go version
go version devel +5b509d993d Tue Oct 13 08:36:41 2020 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"

What did you do?

Pass a zero reflect.Value to Value.Set, as an argument.

https://play.golang.org/p/hynNVbNp4-L

What did you expect to see?

An error that puts the culprit on Value.Set's argument, not on its receiver. Something like:

panic: reflect: zero Value passed to reflect.Value.Set

What did you see instead?

A ValueError like this:

panic: reflect: call of reflect.Value.Set on zero Value

According to the docs:

A ValueError occurs when a Value method is invoked on a Value that does not support it. Such cases are documented in the description of each method.

But that's not what's really happening here. The receiving Value does support Set. It's the argument which is wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions