Skip to content

Emit "pure expression does nothing in statement position" warning #2804

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 2 commits into from
Jun 24, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 24, 2017

No description provided.

@odersky odersky requested a review from smarter June 24, 2017 10:30
@odersky odersky force-pushed the add-pure-warning branch from 5fa07fc to 70eaa36 Compare June 24, 2017 11:51
@smarter smarter merged commit d39dfc0 into scala:master Jun 24, 2017
@lrytz
Copy link
Member

lrytz commented Jun 24, 2017

See also scala/bug#10317 for a limitation of the current implementation in scalac, and it seems to be the same here

@allanrenucci allanrenucci deleted the add-pure-warning branch December 14, 2017 16:57
@som-snytt
Copy link
Contributor

footnote that lrytz example warns

Welcome to Scala 3.4.0-RC1-bin-SNAPSHOT-git-5454110 (21, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> def f(i: Int): Int = { if (i == 42) 27; 17 }
1 warning found
-- [E190] Potential Issue Warning: -------------------------------------------------------------------------------------
1 |def f(i: Int): Int = { if (i == 42) 27; 17 }
  |                                    ^^
  |                                    Discarded non-Unit value of type Int. You may want to use `()`.
  |
  | longer explanation available when compiling with `-explain`
def f(i: Int): Int

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

Successfully merging this pull request may close these issues.

4 participants