Skip to content

Wnonunit-statement must specify match branch, etc #12653

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

Open
som-snytt opened this issue Sep 26, 2022 · 4 comments
Open

Wnonunit-statement must specify match branch, etc #12653

som-snytt opened this issue Sep 26, 2022 · 4 comments
Labels
Milestone

Comments

@som-snytt
Copy link

Reproduction steps

Warning on a large match, where one of the cases has an interesting result, doesn't show which case(s) is interesting.

Problem

It's not usable on matches of appreciable size.

Also, it reports "result type" but not the tree shape; that is, perhaps under verbose flag, show the tree.

@som-snytt
Copy link
Author

Also it's not handling sb.append(x).append(y). I must have dreamt that.

Also p.asInstanceOf[T].m. Also p.synchronized.

Also nested unibranch if in result position.

That's from a pass over the code base.

@som-snytt som-snytt changed the title Wnonunit-statement must specify match branch Wnonunit-statement must specify match branch, etc Sep 28, 2022
@SethTisue SethTisue added the lint label Sep 29, 2022
@SethTisue SethTisue added this to the Backlog milestone Jan 13, 2023
@SethTisue
Copy link
Member

SethTisue commented Jan 13, 2023

Perhaps Scala 3 will do better once it has -Wnonunit-statement at all :-)

@som-snytt
Copy link
Author

som-snytt commented Jun 12, 2023

@SethTisue No, it has the same issue. (Or one of them.)

-- [E176] Potential Issue Warning: test/files/pos/t12653.scala:19:84 ---------------------------------------------------
19 |    buf.append("symbol table = " + (if (syms.length == 0) "<empty>" else "")).append(EOL)
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |    unused value of type (buf : StringBuilder)
2 warnings found

So arguably it does better. Edit, no it's just failing to warn, such as:

test/files/pos/t12653.scala:25: warning: unused value of type C (add `: Unit` to discard silently)
  def morely(): Unit = new C().more("hello").more(", ").more("world")

@som-snytt
Copy link
Author

Possibly I assumed incorrectly that XML literals are a chain of appends. Instead, they are a series of updates, but the API did not return this.type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants