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

"possible missing interpolator: detected interpolated identifier" warning when using s2 #1237

Closed
yanns opened this issue May 13, 2024 · 12 comments

Comments

@yanns
Copy link

yanns commented May 13, 2024

When using s2, the scalac compiler emits this warning:

possible missing interpolator: detected interpolated identifier

Example:

  def is = s2"""
  ChangeSubscription should
    ignore invalid messages                                 $invalidMessagesAreIgnored
  """

  def invalidMessagesAreIgnored: MatchResult[Any] = { ... }

produces:

possible missing interpolator: detected interpolated identifier `$invalidMessagesAreIgnored`
@yanns
Copy link
Author

yanns commented May 13, 2024

This happens when updating from 2.13.13 to 2.13.14.

@etorreborre
Copy link
Owner

I tried to reproduce this issue but this works for me. Can you reproduce this on a smaller project?

@yanns
Copy link
Author

yanns commented May 13, 2024

I have checked deeper, and I could find the specific scalac flags one needs to use to reproduce this behavior:

Seq(
  "-Wmacros:after",
  "-Xlint:missing-interpolator",
)

@etorreborre
Copy link
Owner

Thanks, I can reproduce it now. I have no idea on how to fix this though, this looks like a compiler bug because s2 is definitely specifiied. Would macros:before work for you? Because that one does not raise a warning.

@yanns
Copy link
Author

yanns commented May 14, 2024

Would macros:before work for you? Because that one does not raise a warning.

Sadly not, as it's marking lots of implicits as not used as they're being used in some derivation macros.

My current solution is that use:

  @nowarn("msg=possible missing interpolator")
  def is = s2"""

Not perfect. Let's see if the next scalac version fixes this false positive so that I can remove the @nowarn annotation.

@etorreborre
Copy link
Owner

Sorry about that. I left a question on the Discourse forum to see if I should create a scalac bug next.

@som-snytt
Copy link
Contributor

I responded on the forum, but the new option -Wmacros:default (which is the new default) will probably work better (it is -Wmacros:before but also find more usages after expansion), and also turns off the lint during expansion (which was the previous behavior).

@etorreborre
Copy link
Owner

Thanks @som-snytt! I thought I had tested it, but it seems to work ok. @yanns would that work on your full project?

@yanns
Copy link
Author

yanns commented May 15, 2024

Yes it's an acceptable solution for me. Thanks to both of you!

@yanns
Copy link
Author

yanns commented May 16, 2024

This is maybe a possible solution when using -Wmacros:after: eed3si9n/expecty#161

@etorreborre
Copy link
Owner

@yanns at this stage, I don't think I will dare touching the old macro code 💣, unless there's really no way out :-).

@som-snytt
Copy link
Contributor

I think the burden is on the user of -Wmacros to also -Wconf. (My tweak for expecty is a bit silly and niche.)

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