mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
reflect: add type check to Value.Field()
This commit is contained in:
committed by
Damian Gryski
parent
069c397975
commit
584a2718d0
@@ -568,6 +568,9 @@ func (v Value) Elem() Value {
|
|||||||
|
|
||||||
// Field returns the value of the i'th field of this struct.
|
// Field returns the value of the i'th field of this struct.
|
||||||
func (v Value) Field(i int) Value {
|
func (v Value) Field(i int) Value {
|
||||||
|
if v.Kind() != Struct {
|
||||||
|
panic(&ValueError{Method: "Field", Kind: v.Kind()})
|
||||||
|
}
|
||||||
structField := v.typecode.rawField(i)
|
structField := v.typecode.rawField(i)
|
||||||
flags := v.flags
|
flags := v.flags
|
||||||
if structField.PkgPath != "" {
|
if structField.PkgPath != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user