-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
strconv.Parse{Float,Int,Uint}
is frequently used in the implementation of other grammars (e.g., JSON), which may be a subset or superset of what strconv.ParseX
currently does today. However, what strconv.Parse
does today is not well-specified. What exactly is the input grammar that is accepted?
For example, the documentation for ParseFloat
only says "If s is well-formed", but does not specify what "well-formed" means. I suspect that the answer to this is whether the input is well-formed according to the grammar in the Go specification. If so, this needs to be documented.
Furthermore, this also opens the question for whether the input grammar is stable. Apparently, this is not the case since strconv.ParseX
was recently augmented to support the new number literal grammars (CL/160241 and CL/160244). This change is going to silently break a number of use-cases that were assuming that the input of ParseX
was constrained to the grammar prior to Go1.13. If so, the instability of the input grammar should also be documented.
(BTW, I think the change in semantics is entirely reasonable and I support it; but I see a lot of code silently broken by this change. Documenting this better would help dissuade future abuse.)
\cc @cybrcodr, @griesemer, @rsc