fix(decode): decode into a defined string or bool type
Assisted-by: DeepSeek V4.1 Flash
This commit is contained in:
@@ -202,7 +202,10 @@ func setBasic(dst, val reflect.Value, kind string) error {
|
||||
if dst.Kind() != val.Kind() {
|
||||
return fmt.Errorf("interpres: cannot assign %s to %s", kind, dst.Type())
|
||||
}
|
||||
dst.Set(val)
|
||||
// Convert rather than assign: a value of the predeclared type is not
|
||||
// assignable to a defined type of the same kind, so a plain Set panics on
|
||||
// a destination such as `type Name string`.
|
||||
dst.Set(val.Convert(dst.Type()))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user