mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +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.
|
||||
func (v Value) Field(i int) Value {
|
||||
if v.Kind() != Struct {
|
||||
panic(&ValueError{Method: "Field", Kind: v.Kind()})
|
||||
}
|
||||
structField := v.typecode.rawField(i)
|
||||
flags := v.flags
|
||||
if structField.PkgPath != "" {
|
||||
|
||||
Reference in New Issue
Block a user