fix(decode): decode into a defined string or bool type

Assisted-by: DeepSeek V4.1 Flash
This commit is contained in:
2026-09-19 02:40:51 +02:00
parent 942c4b1489
commit 9023784da3
3 changed files with 33 additions and 1 deletions
+4 -1
View File
@@ -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
}