fastparse icon indicating copy to clipboard operation
fastparse copied to clipboard

@nowarn annotation does not suppress any warnings

Open soufianexmx opened this issue 2 years ago • 14 comments

Using Scala 2.13, after upgrading to version 3.0.1, for a code like:

private def string[A: P]: P[String]   = P(CharIn("a-zA-Z0-9").rep(1).!)

we get compilation error:

@nowarn annotation does not suppress any warnings

soufianexmx avatar Apr 26 '23 08:04 soufianexmx

Same here. Reproduces both with Scala 2.13.10 and 3.2.2

limansky avatar May 19 '23 23:05 limansky

presumably this started with https://github.com/com-lihaoyi/fastparse/pull/281

SethTisue avatar Jun 29 '23 14:06 SethTisue

we get compilation error

well, presumably just a warning, that you have yourself promoted to an error with -Werror?

if someone is looking for a workaround, I think "@nowarn annotation does not suppress any warning" is itself a warning that can be suppressed with @nowarn?

SethTisue avatar Jun 29 '23 14:06 SethTisue

I tried to add @nowarn("msg=@nowarn annotation does not suppress any warnings") (or generic @nowarn) at the class and method using macro level, and it does not suppress the warning (and add a new @nowarn annotation does not suppress any warnings)

fanf avatar Jun 29 '23 15:06 fanf

I wasn't able to find an other way than disabling useless nowarn warning with -Wconf:cat=unused-nowarn:s (see https://www.scala-lang.org/api/current/scala/annotation/nowarn.html). I would prefer that scalac don't report nowarn inside macro, because as the user of the macro, I can't do anything about them.

fanf avatar Jun 29 '23 15:06 fanf

So, one can selectively silent the problematic warning on specific file but keep them for other files with combined filter. For ex: -Wconf:cat=unused-nowarn&src=com/normation/utils/Version.scala:s,cat=unused-nowarn&src=com/normation/rudder/services/policies/InterpolatedValueCompiler.scala:s

Will silent the @nowarn annotation does not suppress any warnings warnings in com/normation/utils/Version.scala and com/normation/rudder/services/policies/InterpolatedValueCompiler.scala, but keep them in other files. More info with scala -Wconf:help

This is good enought for the time being for me.

fanf avatar Jun 30 '23 08:06 fanf

Somehow I'm not able to reproduce this inside my test suite. Would appreciate any help if someone wants to look into this inside the Fastparse repo and come up with a repro

lihaoyi avatar Jul 10 '23 01:07 lihaoyi

@lihaoyi I don't know if this is related, but here's the error I got for 2.13.1 (and only that version): https://github.com/scalameta/scalameta/actions/runs/5503580335/jobs/10028930479?pr=3246

kitbellew avatar Jul 10 '23 03:07 kitbellew

Maybe it's specific to particular Scala versions? @soufianexmx @limansky @fanf what Scala versions are you guys seeing this in?

lihaoyi avatar Jul 10 '23 05:07 lihaoyi

2.13.10 for me I think.

Bathtor avatar Jul 10 '23 07:07 Bathtor

We first saw it in 2.13.10, and I checked it's still the case in 2.13.11

fanf avatar Jul 10 '23 08:07 fanf

@lihaoyi I've tried with both 2.13.10 and 2.13.11. It looks like you have to have -Xlint in your scalacOptions.

limansky avatar Jul 10 '23 10:07 limansky

Ah I think it must be the -Xlint flag that I've been missing

lihaoyi avatar Aug 08 '23 02:08 lihaoyi

@lihaoyi Hi, I've checked 3.0.2 and the issue is still there. Please let me know if you need minimal example to demonstrate the problem.

limansky avatar Oct 20 '23 14:10 limansky

I'm using Fastparse too in a Java project, I would like to give this a try, this weekend.

He-Pin avatar May 15 '24 06:05 He-Pin

@He-Pin please go ahead!

lihaoyi avatar May 17 '24 00:05 lihaoyi

Should be fixed by https://github.com/com-lihaoyi/fastparse/pull/310

lihaoyi avatar May 19 '24 07:05 lihaoyi

👏

SethTisue avatar May 20 '24 18:05 SethTisue