-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add -Wtostring-interpolated
to warn if interpolator uses toString
#10776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -Wtostring-interpolated
to warn if interpolator uses toString
#10776
Conversation
6e463fb
to
ab4a1d1
Compare
Previous feedback at wartremover is to allow at least Therefore, no accommodation is made yet here. A future version can take a typeclass, implicit locale, etc. |
ab4a1d1
to
cbf369d
Compare
cbf369d
to
dc21f58
Compare
Added the exclusion for primitives but not Dotty reflect says don't use
|
spurious error on first commit after rebase
then
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise! I'm not familiar with the code though.
dc21f58
to
6afc3a5
Compare
gah
|
/rebuild |
fool me twice
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you! Let's squash before merge.
d138e6c
to
1ac2451
Compare
Squashed & rebased for ✔️ (🤞 ) |
Adds -Wtostring-interpolated
to warn if interpolator uses toString
Adds -Wtostring-interpolated
to warn if interpolator uses toString
-Wtostring-interpolated
to warn if interpolator uses toString
Adds
-Wtostring-interpolated
which warns if a standard interpolator usestoString
to convert a value which is not string or primitive type.-Wconf:cat=w-flag-tostring-interpolated:e
to boost.Also restores edge case
f"${ "hello" }%b"
which is"true"
for non-boolean arg. That became an error in previous refactor, possibly intentionally. (It is arguably an obscure feature of format.) (Edit: the C.I. error reminds me that the change was to make the expected type Boolean, so that conversions work normally. That is also edge casey. Maybe it can try boolean, null, and any? Edit: yes, try non-any first, then any if allowed.)The "default"
%s
is improved so that the warning position is at the interpolated element ins"$x"
.Follow-up to #8654