You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quoting from a separate bug report:
I didn't see what the defined behavior of the fmt.printf family of functions should be
to the format pair %_, where _ is any character not defined as a verb. (This happened as
a result of an unrelated error). Currently the code in fmt/print.go, lines 1096-1100
assumes that whatever follows the '%' is a valid verb, and charges ahead. (This might be
what you want to do, but perhaps it should be documented, if so) In the example, text
generated by html/template was inadvertently handed to Fprintf, and gave the somewhat
unintuitive message as shown.
package main
import "fmt"
func main() {
fmt.Println(fmt.Sprintf(".%2a%3a4.1%3a29"))
}
gives
.%a(MISSING)%a(MISSING)4.1%a(MISSING)29
This could be fixed by skipping over, and emitting the %_, or giving %a(NOT-VERB)
The text was updated successfully, but these errors were encountered:
This is a confusing example (Println of Sprintf for some reason, and then no arguments,
so there are multiple things happening). The error reported is mostly about missing
arguments, not bad format verbs, so the complaint is malformed. But let's take it at
face value with a proper example:
fmt.Printf("%w\n", 3)
which gives
%!w(int=3)
That seems like a reasonable error message. You get the erroneous verb reported, and the
value is printed regardless. The provided example with arguments:
fmt.Printf(".%2a%3a4.1%3a29\n", 3, 4, 5)
which gives
.%!a(int= 3)%!a(int= 4)4.1%!a(int= 5)29
I claim that's fine. Verbs in general cannot be outlawed, since a Formatter interface is
allowed to take any verb at all. We could check that a Formatter is being used and then
complain, but the way we complain wouldn't really be any different.
Working as intended.
The text was updated successfully, but these errors were encountered: