Skip to content

open is not treated as a normal identifier inside match #15960

@andrelfpinto

Description

@andrelfpinto

Compiler version

3.1.3

Minimized code

class Foo(open: String) {
  def bar(n: Int) = n match {
    case 0 => open
    case _ => throw new IndexOutOfBoundsException()
  }
  def baz() = open
}

Output

-- [E088] Syntax Error: Open.scala:4:4 ----------------------------------------------------
4 |    case _ => throw new IndexOutOfBoundsException()
  |    ^^^^
  |    Expected start of definition

Explanation
===========
You have to provide either class, trait, object, or enum definitions after qualifiers

1 error found

Expectation

bar should compile as baz does.

According to this:

open is a soft modifier. It is treated as a normal identifier unless it is in modifier position.

It seems like open is not being treated as a normal identifier inside match.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions