lang: types: Avoid a panic if it's not settable
We should check this for safety. An error is better than a panic. If we try to set an unexported field, this would panic. We should prevent being able to even type unify that though!
This commit is contained in:
@@ -263,6 +263,9 @@ func Into(v Value, rv reflect.Value) error {
|
|||||||
}
|
}
|
||||||
rv = rv.Elem() // un-nest rv from pointer
|
rv = rv.Elem() // un-nest rv from pointer
|
||||||
}
|
}
|
||||||
|
if !rv.CanSet() {
|
||||||
|
return fmt.Errorf("can't set value, is it unexported?")
|
||||||
|
}
|
||||||
|
|
||||||
// capture rv and v in a closure that is static for the scope of this Into() call
|
// capture rv and v in a closure that is static for the scope of this Into() call
|
||||||
// mustInto ensures rv is in a list of compatible types before attempting to reflect it
|
// mustInto ensures rv is in a list of compatible types before attempting to reflect it
|
||||||
|
|||||||
Reference in New Issue
Block a user