Skip to content

Braceless catch catches too much #8096

Closed
@som-snytt

Description

@som-snytt

minimized code

This works as expected if the case is on the line following the catch, at same or greater indent.

  def k: String =
    try
      "WUT"
    catch case t => println(s"Caught a case of $t")

    "OK"
Compilation output
      def k: String = 
        try "WUT" catch 
          {
            case t @ _ => 
              println(
                _root_.scala.StringContext.apply(
                  ["Caught a case of ","" : String]:String*
                ).s([t : Any]:Any*)
              )
              "OK"
          }

expectation

"OK" result is not in the body of the catch case.

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