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

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

Closed
soufianexmx opened this issue Apr 26, 2023 · 18 comments
Closed

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

soufianexmx opened this issue Apr 26, 2023 · 18 comments

Comments

@soufianexmx
Copy link

soufianexmx commented Apr 26, 2023

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
Copy link

Same here. Reproduces both with Scala 2.13.10 and 3.2.2

@SethTisue
Copy link
Contributor

presumably this started with #281

@SethTisue
Copy link
Contributor

SethTisue commented Jun 29, 2023

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
Copy link

fanf commented Jun 29, 2023

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
Copy link

fanf commented Jun 29, 2023

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
Copy link

fanf commented Jun 30, 2023

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
Copy link
Member

lihaoyi commented Jul 10, 2023

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
Copy link

@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
Copy link
Member

lihaoyi commented Jul 10, 2023

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

@Bathtor
Copy link

Bathtor commented Jul 10, 2023

2.13.10 for me I think.

@fanf
Copy link

fanf commented Jul 10, 2023

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

@limansky
Copy link

@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
Copy link
Member

lihaoyi commented Aug 8, 2023

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

@limansky
Copy link

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

@lihaoyi lihaoyi changed the title @nowarn annotation does not suppress any warnings @nowarn annotation does not suppress any warnings (100USD Bounty) May 14, 2024
@lihaoyi lihaoyi changed the title @nowarn annotation does not suppress any warnings (100USD Bounty) @nowarn annotation does not suppress any warnings (200USD Bounty) May 14, 2024
@He-Pin
Copy link
Contributor

He-Pin commented May 15, 2024

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

@lihaoyi
Copy link
Member

lihaoyi commented May 17, 2024

@He-Pin please go ahead!

lihaoyi pushed a commit that referenced this issue May 19, 2024
Motivation:
refs: #285
with reading:
https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html

Modification:
1. I updated some depenecies,both scala and etc
2. because of com-lihaoyi/mill#3167, I have to
comments out the native modules locally
3. add `-Xlint:unused` to reproduce the problem
4. updated some tests when `3` is enabled.
5. remove 2.11 related code
6. as Scala 2.12.x now supports the nowarn , so I changed the code to
use the `@nowarn` annotation directly.
7. the root cause is the annotation in `WhiteSpace` macro

Result:
I think the issue is fixed now, and as I'm using Fastparse within a Java
project, so I was not knowing this issue.
All tests passed locally.
@lihaoyi
Copy link
Member

lihaoyi commented May 19, 2024

Should be fixed by #310

@lihaoyi lihaoyi closed this as completed May 19, 2024
@SethTisue
Copy link
Contributor

👏

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

8 participants