com-lihaoyi / fastparse

Writing Fast Parsers Fast in Scala
https://com-lihaoyi.github.io/fastparse
MIT License
1.09k stars 164 forks source link

@nowarn annotation does not suppress any warnings (200USD Bounty) #285

Closed soufianexmx closed 2 months ago

soufianexmx commented 1 year ago

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

Haoyi: To incentivize contribution, I'm putting a 200USD bounty on resolving this ticket. This is payable via bank transfer, and at my discretion in case of ambiguity. The acceptance criteria is a PR fixing this issue and updates to our test infrastructure to validate the fix

limansky commented 1 year ago

Same here. Reproduces both with Scala 2.13.10 and 3.2.2

SethTisue commented 1 year ago

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

SethTisue commented 1 year ago

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?

fanf commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.

lihaoyi commented 1 year ago

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

kitbellew commented 1 year ago

@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

lihaoyi commented 1 year ago

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

Bathtor commented 1 year ago

2.13.10 for me I think.

fanf commented 1 year ago

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

limansky commented 1 year ago

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

lihaoyi commented 11 months ago

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

limansky commented 9 months ago

@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.

He-Pin commented 2 months ago

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

lihaoyi commented 2 months ago

@He-Pin please go ahead!

lihaoyi commented 2 months ago

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

SethTisue commented 2 months ago

👏