Skip to content

REPL does not report unused warning #16917

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

Closed
som-snytt opened this issue Feb 14, 2023 · 1 comment
Closed

REPL does not report unused warning #16917

som-snytt opened this issue Feb 14, 2023 · 1 comment

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.3.1-RC1-bin-SNAPSHOT-git-8c616bf

Minimized code

  snips cat private.scala

class C {
  private def f = 42
}
  snips ~/projects/dotty/bin/scalac -Wunused:privates -d /tmp private.scala
-- Warning: private.scala:3:14 -----------------------------------------------------------------------------------------
3 |  private def f = 42
  |              ^
  |              unused private member
1 warning found
  snips ~/projects/dotty/bin/scala -Wunused:privates
Welcome to Scala 3.3.1-RC1-bin-SNAPSHOT-git-8c616bf (19, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> class C {
     |   private def f = 42
     | }
// defined class C

Output

As shown.

Expectation

Expect warning in scala REPL as for same code in scalac.

Noticed at #16823 (comment)

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 14, 2023
@WojciechMazur WojciechMazur added area:repl and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 15, 2023
@prolativ prolativ self-assigned this Feb 15, 2023
@som-snytt
Copy link
Contributor Author

Onward and upward!

➜  dotty git:(test/repl-unused) ./bin/scala -Wunused:all
Welcome to Scala 3.4.0-RC1-bin-SNAPSHOT-git-c90ad6b (20.0.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> class C { private def f = 42 }
1 warning found
-- Warning: ------------------------------------------------------------------------------------------------------------
1 |class C { private def f = 42 }
  |                      ^
  |                      unused private member
// defined class C

scala>

Same result with -Wunused:privates, just to be paranoid.

Also

scala> class C:
     |   private def f = 42
     | end C
1 warning found
// defined class C
-- Warning: ------------------------------------------------------------------------------------------------------------
2 |  private def f = 42
  |              ^
  |              unused private member

scala>

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

No branches or pull requests

3 participants