| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
the large set of code comments made this much easier to review, thanks!
wrap := func(start, end token.Pos, before, after string) []analysis.TextEdit {Naming is a bit confusing here for me. When I was reading the use of the function below, I was getting confused at where the "x" was being inserted, then I remembered that it's wrapping the "x".
Maybe less of a naming issue, but more that the call to the wrap doesn't easily distinguish `before` vs `after`. I can't think of an easy remedy, so feel free to just ignore this comment!
addFix("Format the number as a decimal", sprintf("d"))Do we want to highlight to the user that this is possibly behavior changing? Compared to the possible other suggested fix? And maybed we highlight that Fix 1 is behavior preserving?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
wrap := func(start, end token.Pos, before, after string) []analysis.TextEdit {Naming is a bit confusing here for me. When I was reading the use of the function below, I was getting confused at where the "x" was being inserted, then I remembered that it's wrapping the "x".
Maybe less of a naming issue, but more that the call to the wrap doesn't easily distinguish `before` vs `after`. I can't think of an easy remedy, so feel free to just ignore this comment!
Fair point. I melted `wrap` down and extracted `edit`, a trivial constructor for one TextEdit.
Do we want to highlight to the user that this is possibly behavior changing? Compared to the possible other suggested fix? And maybed we highlight that Fix 1 is behavior preserving?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
go/analysis/passes/stringintconv: make first fix behavior-preserving
Go 1.28 rejects string(x) conversions where x is a non-byte,
non-rune integer (go.dev/issue/3939). To let "go fix" migrate code
before a module's go directive is raised to go1.28, this CL makes
the analyzer's first suggested fix preserve the existing behavior,
and adds the analyzer to the go fix suite.
The old "Convert a single rune to a string" fix, string(rune(x)),
was not behavior-preserving for types wider than 32 bits due to
truncation. For such types the fix now uses fmt.Sprintf("%c", x),
which is exactly equivalent to string(x). The plain rune(x) form is
still used for constants that fit in 32 bits and for types of at
most 32 bits.
The safe fix is now offered first, since that's what go fix applies.
The decimal-formatting fix, which changes behavior, is second; it now
uses fmt.Sprintf("%d", x), for symmetry, instead of fmt.Sprint(x).
If no behavior-preserving fix is available no fixes are offered at
all, so that go fix never applies the second fix.
Also:
- simplify the edits of both Sprintf fixes by choosing the range to
rewrite once: string(x) -> fmt.Sprintf(...), and
mystring(x) -> mystring(fmt.Sprintf(...)).
This fixes a bug in the old fmt.Sprint fix, which dropped the
conversion S(x) when S was a type parameter whose sole term
is string, yielding an ill-typed result.
- update the doc, which recommended strconv.Itoa.
Updates golang/go#81760
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |