fix(encode): reject a nil MarshalTOML result

Assisted-by: GLM 5.3
This commit is contained in:
2026-09-17 23:11:10 +02:00
parent d5327568fb
commit 4def1b3e8b
4 changed files with 61 additions and 2 deletions
+4 -1
View File
@@ -309,7 +309,10 @@ The returned value is encoded as if it had been passed in place of the
receiver, so it may be a scalar, a slice, an array of tables, or another
struct or map, including the `Marshaler` result of another type; the encoder
recurses. An error returned from `MarshalTOML` fails the marshal wrapped with
the key path, for example `interpres: server.port: bad timestamp`.
the key path, for example `interpres: server.port: bad timestamp`. A result
of `nil` with a nil error fails the same way with
`MarshalTOML returned a nil value`: nil has no TOML representation, so
dropping the field silently is not an option.
```go
type Port int