{'%', noFlag, 0},
{'b', numFlag, argInt | argFloat | argComplex},
{'c', "-", argRune | argInt},
- {'d', numFlag, argInt},
+ {'d', numFlag, argInt | argPointer},
{'e', sharpNumFlag, argFloat | argComplex},
{'E', sharpNumFlag, argFloat | argComplex},
{'f', sharpNumFlag, argFloat | argComplex},
{'T', "-", anyType},
{'U', "-#", argRune | argInt},
{'v', allFlags, anyType},
- {'x', sharpNumFlag, argRune | argInt | argString},
- {'X', sharpNumFlag, argRune | argInt | argString},
+ {'x', sharpNumFlag, argRune | argInt | argString | argPointer},
+ {'X', sharpNumFlag, argRune | argInt | argString | argPointer},
}
// okPrintfArg compares the formatState to the arguments actually present,
fmt.Printf("%G %G %G %G", 3e9, x, fslice, c)
fmt.Printf("%b %b %b %b", 3e9, x, fslice, c)
fmt.Printf("%o %o", 3, i)
- fmt.Printf("%p %p", p, nil)
+ fmt.Printf("%p", p)
fmt.Printf("%q %q %q %q", 3, i, 'x', r)
fmt.Printf("%s %s %s", "hi", s, []byte{65})
fmt.Printf("%t %t", true, b)
fmt.Printf("%g", imap) // ERROR "Printf format %g has arg imap of wrong type map\[int\]int"
fmt.Printf("%G", i) // ERROR "Printf format %G has arg i of wrong type int"
fmt.Printf("%o", x) // ERROR "Printf format %o has arg x of wrong type float64"
+ fmt.Printf("%p", nil) // ERROR "Printf format %p has arg nil of wrong type untyped nil"
fmt.Printf("%p", 23) // ERROR "Printf format %p has arg 23 of wrong type int"
fmt.Printf("%q", x) // ERROR "Printf format %q has arg x of wrong type float64"
fmt.Printf("%s", b) // ERROR "Printf format %s has arg b of wrong type bool"
Printf("%d", notPercentDV) // ERROR "Printf format %d has arg notPercentDV of wrong type testdata.notPercentDStruct"
Printf("%d", ¬PercentDV) // ERROR "Printf format %d has arg ¬PercentDV of wrong type \*testdata.notPercentDStruct"
Printf("%p", ¬PercentDV) // Works regardless: we print it as a pointer.
+ Printf("%q", &percentDV) // ERROR "Printf format %q has arg &percentDV of wrong type \*testdata.percentDStruct"
Printf("%s", percentSV)
Printf("%s", &percentSV)
// Good argument reorderings.
if str, ok := typ.Elem().Underlying().(*types.Struct); ok {
return f.matchStructArgType(t, str, arg, inProgress)
}
- // The rest can print with %p as pointers, or as integers with %x etc.
- return t&(argInt|argPointer) != 0
+ // Check whether the rest can print pointers.
+ return t&argPointer != 0
case *types.Struct:
return f.matchStructArgType(t, typ, arg, inProgress)
return t&(argInt|argRune) != 0
case types.UntypedNil:
- return t&argPointer != 0 // TODO?
+ return false
case types.Invalid:
if *verbose {
defer time.ResetZoneinfoForTesting()
if zoneinfo := time.ZoneinfoForTesting(); testZoneinfo != *zoneinfo {
- t.Errorf("zoneinfo does not match env variable: got %q want %q", zoneinfo, testZoneinfo)
+ t.Errorf("zoneinfo does not match env variable: got %q want %q", *zoneinfo, testZoneinfo)
}
}