Skip to content

defining and using enum inside def produces runtime stack overflow #10139

Closed
@weihsiu

Description

@weihsiu

Minimized code

object EnumTest:
  @main
  def run(): Unit =
    try
      enum Color:
        case Red, Green, Blue
      def paint(color: Color): Unit =
        println(s"painting with color $color")
      paint(Color.Red)
    catch
      case e => println(e)

Output

java.lang.StackOverflowError

Expectation

painting with color Red

after defining and using an enum inside a function, when the function is ran, it produces a StackOverflowError. if the enum is defined outside of the function, then everything works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions