Skip to content

Broken error message when trying to eta-expand a by-name #4157

Closed
@smarter

Description

@smarter
object Test {
  def foo(x: => Int) ={
    val a = x _ // error
    val b: () => Int = x _ // error
  }
}

The first error message is correct, but the second leaks the ErrorType and thus looks confusing:

-- [E099] Syntax Error: try/byeta.scala:3:14 -----------------------------------
3 |    val a = x _ // error
  |            ^^^
  |            Not a function: => Int(x): cannot be followed by _

longer explanation available when compiling with `-explain`
-- [E099] Syntax Error: try/byeta.scala:4:25 -----------------------------------
4 |    val b: () => Int = x _ // error
  |                       ^^^
  |                       Not a function: <error found:    Int
  |                       required: () => Int
  |                       
  |                       >: cannot be followed by _

Metadata

Metadata

Assignees

Labels

area:reportingError reporting including formatting, implicit suggestions, etcitype:bugprio:low

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions