Skip to content

Eta expansion undesirable when result will be immediately discarded #11761

Closed
@japgolly

Description

@japgolly

Compiler version

3.0.0-RC1

Minimized code

def go(x: Int): Unit =
  go

Output

[warn] -- [E129] Potential Issue Warning: /home/golly/projects/public/univeq/univeq/shared/src/main/scala-3/japgolly/univeq/internal/bug.scala:2:2 
[warn] 2 |  go
[warn]   |  ^^
[warn]   |A pure expression does nothing in statement position; you may be omitting necessary parentheses

Expectation

The code shouldn't compile. The go function requires an explicit x argument. It's probably converting go to a function literal which is normally fine, but doesn't make sense if its the entirely of the statement and not a return value.

(Also keep in mind that this is the minimised case, the real case I encountered was much more confusing and dangerous.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions