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
Fix #93 Wart for implicit toString in String concatenation and interpolation #388
base: master
Are you sure you want to change the base?
Conversation
… and interpolation
This would be really great - it's so easy to write I would suggest keeping the ban on What do you think, @tim-zh ? |
@pmpfr Why these types? It could be |
I'm not sure I understand your question. You can certainly always define a What I am saying is that you shouldn't need to do that for My suggestion is that for those types, there is no reasonable possibility of actually meaning a different string representation than the one If you are questioning why I exclude |
I like those exceptions (otherwise the |
Yes. "Natural" representation is a vague thing. On the one hand, any type has a standard one, which is result of |
I mean, ideally I'm sure we've all hit a bug where we meant to output "foo" but actually output "Some(foo)" but it's less common that you really wanted "IV" instead of "4". We can always add a wart that bans |
I suppose for me it comes down to this. I don't think it's reasonable for Wartremover to stop people writing The reason for the difference being that I think there are a small number of types which people are "born knowing" their toString representation. There's so little room for doubt that it's reasonable (IMO) to rely on it in production code, that they're round-trip safe and suitable for machine parsing. None of that is true (IMO) for any other toString implementation. So I want wartremover to warn me about any other implicit |
Interesting idea! Retronym has a PR to convert interpolation to string + in refchecks, where the backend emits efficient string builder etc. That's ok bc the plug-in runs earlier. It makes me think current scheme allowing only string args is best as it avoids boxing, perhaps. But I also think it effectively outlaws s & raw. It would break all my debug strings. Probably I should use a debug interpolator. The idea to allow int and char is ok but wouldn't enable me to use it. As mentioned everyone should use prettyprinting typeclass. The check for f interpolation or arbitrary format strings would be tricky albeit doable. |
I quite forgot that I'd left some famous last words here. Standard interpolators are now intrinsic, expanded at typer in Scala 2 and much later in Scala 3. If I want |
No description provided.