Skip to content

Braceless catch catches too much #8096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
som-snytt opened this issue Jan 27, 2020 · 0 comments
Closed

Braceless catch catches too much #8096

som-snytt opened this issue Jan 27, 2020 · 0 comments

Comments

@som-snytt
Copy link
Contributor

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.

bishabosha added a commit that referenced this issue Jan 30, 2020
Fix #8096: Change syntax of single-case try
bishabosha added a commit to dotty-staging/dotty that referenced this issue Jan 30, 2020
odersky added a commit that referenced this issue Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant