pkg/strconv: allow string argument for FormatFloat format parameter
FormatFloat now accepts either a string ("g", "f", etc.) or an integer
(the byte value) for the format parameter. The function signature uses
cue.Value, which the generator maps to adt.TopKind.
This is a re-do of https://cuelang.org/cl/537569,
which was reverted right after being merged as it broke `go generate`.
The original fix moved FormatFloat into manual.go with a custom
builtin registration, but the generator still found the exported
function and produced a conflicting registration in pkg.go.
This version avoids the conflict by using cue.Value in the exported
Go signature, which the generator handles natively.
Using the wider cue.Value parameter does lead to values like -1 or 300
being allowed as arguments, so add a check against the range [0, 255]
to make sure that they continue giving an error.
Fixes #1436.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I014f7cdb5033d9c4fa15f7c8d194f9a915872ca9
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1233875
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>