8000 Show nowarn / Wconf filters for a warning with @nowarn("verbose") by lrytz · Pull Request #10985 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Show nowarn / Wconf filters for a warning with @nowarn("verbose") #10985

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

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

lrytz
Copy link
Member
@lrytz lrytz commented Jan 20, 2025

As already implemented in Scala 3

scala> @nowarn("v") def f = try 1
                            ^
       warning: A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.
       Applicable -Wconf / @nowarn filters for this warning: msg=<part of the message>, cat=other, site=f
def f: Int

(https://hachyderm.io/@spills/112831541923471812)

@lrytz lrytz requested a review from som-snytt January 20, 2025 10:56
@scala-jenkins scala-jenkins added this to the 2.13.17 milestone Jan 20, 2025
@som-snytt
Copy link
Contributor

That is so cool! TIL! and I just made a tweak on dotty about nowarn and didn't notice.

Not that I didn't believe you, but I had to try it out on my test file.

  |            unused explicit parameter
Matching filters for @nowarn or -Wconf:
  - id=E198
  - name=UnusedSymbol

Copy link
Contributor
@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize innovations were propagating in this direction.

It's very nice when similarity of code makes porting and reviews easier or possible.

@som-snytt
Copy link
Contributor

Every code base should have class dowarn extends nowarn("v").

That doesn't work yet.

@lrytz
Copy link
Member Author
lrytz commented Jan 20, 2025

Changing compiler flags is much more tedious than adding an annotation to the source and rebuilding.

Scala 3 -explain is an obvious candidate.

For Scala 2, I looked through the settings. Scoped -Vprint would cool, maybe -Vtyper too, but both are for advanced users. -Vcyclic is a global flag, I don't think an annotation would work for that.

So maybe -explain is the only real opportunity. I'll create a ticket to see if they like the idea, if they want to reuse @nowarn("v") for that, or some new annotation.

As already implemented in Scala 3

```
scala> @nowarn("v") def f = try 1
                            ^
       warning: A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.
       Applicable -Wconf / @nowarn filters for this warning: msg=<part of the message>, cat=other, site=f
def f: Int
```
@som-snytt
Copy link
Contributor

flags vs annotations is sad but true. Also counter-intuitive from an old school perspective. Modifying source is heavyweight, but because of the "build tool", flipping an option is heavier.

I don't use an IDE, although previously I used Eclipse for Java projects, but I can see the "local" use case: there is some weirdness in my code, it shows a red squiggle or perhaps amber, I want to click an icon to show what I can do to silence the squiggle.

That workflow is entirely local.

The missing piece is still an audit to tell me what warnings were modified (locally suppressed) in my code.

@lrytz lrytz added the release-notes worth highlighting in next release notes label Jan 23, 2025
@lrytz lrytz merged commit a7af6f2 into scala:2.13.x Jan 30, 2025
3 checks passed
hamzaremmal pushed a commit to hamzaremmal/scala3 that referenced this pull request May 2, 2025
Show nowarn / Wconf filters for a warning with  @nowarn("verbose")
hamzaremmal pushed a commit to scala/scala3 that referenced this pull request May 7, 2025
Show nowarn / Wconf filters for a warning with  @nowarn("verbose")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0