Skip to content
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

false positive in possible string interpolation warning #8476

Closed
scabug opened this issue Apr 5, 2014 · 8 comments
Closed

false positive in possible string interpolation warning #8476

scabug opened this issue Apr 5, 2014 · 8 comments

Comments

@scabug
Copy link

scabug commented Apr 5, 2014

In the following case no warning should be shown:

scala> """ s"${fo}" """
<console>:8: warning: That looks like an interpolated expression! Did you forget the interpolator?
       """ s"${fo}" """
       ^
res0: String = " s"${fo}" "
@scabug
Copy link
Author

scabug commented Apr 5, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8476?orig=1
Reporter: @sschaef
Affected Versions: 2.11.0
See #8525

@scabug
Copy link
Author

scabug commented Apr 23, 2014

Jed Wesley-Smith (jedws) said:
what is this "feature" and how do we turn it off? We have a warning intolerant build and use this kind of thing for instance using the Typesafe Config library.

Is there a macro that performs no interpolation and avoids this warning?

@scabug
Copy link
Author

scabug commented Apr 23, 2014

Jed Wesley-Smith (jedws) said:
I understand what it does, but I contend it is an anti-feature.

I wrote code (in fact, I didn't I wrote a String literal) and the compiler helpfully warns me that it looks like I might have meant it to be code after all, except I didn't, if I had I would have put a macro in front of it. This is like warning if I use the Int constant 43 that perhaps 42 is a nicer number!

It makes -Xlint far less useful for us currently (we can only turn it on if we workaround the original problem, for instance by externalising the Strings in question, which is sub-optimal.

@scabug
Copy link
Author

scabug commented Apr 23, 2014

@retronym said (edited on Apr 23, 2014 5:30:04 AM UTC):
High on our todo list is to add a config option to let you filter out warnings. Hopefully in 2.11.1.

There is a tension between adding a -Yoption for each warning (maximum flexibility) vs lumping many warnings under Xlint (easier discoverability, smaller command line API).

In the meantime, you can do this yourself in SBT. I remember I helped @puffnfresh configure this a month or so ago. I'll try to dig up the example.

@scabug
Copy link
Author

scabug commented Apr 23, 2014

@retronym said:
It is in the comments of: #8410

@scabug
Copy link
Author

scabug commented Apr 23, 2014

Jed Wesley-Smith (jedws) said:
Thanks @retronym, appreciate the feedback. The suggested approach is a bit heavyweight for this though.

And, my objection to this specific warning as a valid thing stands.

@scabug
Copy link
Author

scabug commented Apr 23, 2014

@retronym said (edited on Apr 23, 2014 5:43:53 AM UTC):
It has revealed quite a few bugs, so it has value. But I agree that it needs to be configurable. I guess you can break up your strings in the mean time if you don't have too many. Or maybe

"""  @{foo} """.replaceAllLiterally("@", "$").

@som-snytt
Copy link

Closing because the example doesn't warn, for some time now, unless the ident is in scope. Also, a filtering reporter is on the horizon for the worst case scenario. Also, the warning can be disabled.

@SethTisue SethTisue removed this from the Backlog milestone Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants