]> Cypherpunks.ru repositories - gostls13.git/commit
reflect: allow conversion from slice to array ptr
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 14 Mar 2021 21:31:50 +0000 (14:31 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 21 Apr 2021 00:54:39 +0000 (00:54 +0000)
commit760d3b2a16544aab553ca7ec6e6ed3bf4dc9aa3f
treea9eac9132e1fa610ecc7af7a4f754cf6dba67dca
parentc18744377afa1f9c2310c122e6932fa663f9294a
reflect: allow conversion from slice to array ptr

Note that this removes an invariant:

v.Type().ConvertibleTo(t) might return true,
yet v.Convert(t) might panic nevertheless.

This is a fairly unavoidable consequence of the decision
to add the first-ever conversion that can panic.

ConvertibleTo describes a relationship between types,
but whether the conversion panics now depends on the value,
not just the type.

If this turns out to be a problem, we can add v.ConvertibleTo(t),
or something similar, to allow callers to avoid the panic.

This is the last of the changes needed to complete the implementation.

Fixes #395

Change-Id: I79b7e4dd87a67a47723e00a65d0b1ac6090371b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/301652
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/reflect/all_test.go
src/reflect/type.go
src/reflect/value.go