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

Open
scabug opened this Issue Apr 5, 2014 · 7 comments

Comments

Projects
None yet
1 participant
@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

scabug commented Apr 23, 2014

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

@scabug

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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("@", "$").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment