fix(decode): overflow-check uint and float32 destinations
Assisted-by: GLM 5.3
This commit is contained in:
+2
-2
@@ -126,8 +126,8 @@ The decoder converts to the destination type with explicit overflow checks:
|
||||
| Destination kind | Rule |
|
||||
|---|---|
|
||||
| `int`, `int8`, `int16`, `int32`, `int64` | the `int64` value must not overflow the destination |
|
||||
| `uint`, `uint8`, `uint16`, `uint32`, `uint64` | the value must be non-negative; `uint8`, `uint16` and `uint32` enforce their own maxima; `uint64` accepts any non-negative `int64` |
|
||||
| `float32`, `float64` | copied verbatim; an integer also coerces, so TOML `5` decodes into `5.0` |
|
||||
| `uint`, `uint8`, `uint16`, `uint32`, `uint64` | the value must be non-negative and must not overflow the destination's own width, `uint` on a 32-bit platform included; `uint64` accepts any non-negative `int64` |
|
||||
| `float32`, `float64` | copied verbatim, except that a finite value beyond the `float32` range is an overflow error rather than a silent infinity; an integer also coerces, so TOML `5` decodes into `5.0` |
|
||||
| `bool`, `string` | exact kind match only, no coercion across kinds |
|
||||
| `time.Time` | offset date-times only; no implicit conversion to or from the local variants |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user