typelevel / weaver-test

A test framework that runs everything in parallel.
https://typelevel.org/weaver-test/
Other
46 stars 8 forks source link

`Expect` macros don't work with string interpolation in Scala 2.13.14 #90

Closed zainab-ali closed 2 weeks ago

zainab-ali commented 2 weeks ago

This issue was copied over from: https://github.com/disneystreaming/weaver-test/issues/750 It was opened by: aragutskiy


After updating Scala from 2.13.13 to 2.13.14 I got compilation error: "possible missing interpolator: detected an interpolated expression".

Doesn't work:

val world = "World"
assert(s"Hello, $world!".contains("Hell"))

Works:

val world = "World"
val assertion = s"Hello, $world!".contains("Hell")
assert(assertion)
zainab-ali commented 2 weeks ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/750#issuecomment-2112872413 It was written by: SethTisue


Curious what happened here — what Scala change was responsible. cc lrytz som-snytt

zainab-ali commented 2 weeks ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/750#issuecomment-2113045617 It was written by: som-snytt


Probably the same as https://github.com/etorreborre/specs2/issues/1237 or explanation on the forum https://users.scala-lang.org/t/regression-with-macro-and-interpolation-linting/9986/2?u=som-snytt

where -Wmacros:after (or -Wmacros:both) enables linting (for this particular lint) the tree after expansion.

Note that the new default -Wmacros:default was improved to make it less likely that -Wmacros:after is intended.

(-Wmacros:none turns off linting of trees that are transformed by macros, either before or after expansion.)

SethTisue It ought to be mentioned in the release notes. It affects only those warning expanded trees, but that may not be a niche of the community.

zainab-ali commented 2 weeks ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/750#issuecomment-2113522551 It was written by: som-snytt


I submitted a provisional PR with expecty, which I assume is used here. That would pass the lint irrespective of other settings.

zainab-ali commented 2 weeks ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/750#issuecomment-2269990320 It was written by: SethTisue


It ought to be mentioned in the release notes

ah, indeed, https://github.com/scala/scala/releases/tag/v2.13.14 references https://github.com/scala/scala/pull/10693

and the expecty PR Som mentions is https://github.com/eed3si9n/expecty/pull/161

zainab-ali commented 2 weeks ago

Closing as a duplicate.