Skip to content
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

fix: use correct ErrorMessageID for EmptyCatchOrFinallyBlock #14786

Merged
merged 1 commit into from
Mar 28, 2022

Commits on Mar 26, 2022

  1. fix: use correct ErrorMessageID for EmptyCatchOrFinallyBlock

    Previously we were always assigning this to `EmptyCatchOrFinallyBlockID`
    but both `EmptyCatchBlock` and `EmptyCatchAndFinallyBlock` both use this
    class and pass in their corresponding `ErrorMessageID`. This caused the
    following two code samples to give the same `ErrorMessageID` when they
    should have been different than they currently are:
    
    ```scala
    try {}
    ```
    
    ```scala
    try {} catch {} finally {}
    ```
    
    The second one gave this as an error:
    
    ```
    scala> try {} catch {} finally {}
    -- [E000] Syntax Error: --------------------------------------------------------
    1 |try {} catch {} finally {}
      |       ^^^^^^^^
      |       The catch block does not contain a valid expression, try
      |       adding a case like - case e: Exception => to the block
      |
      | longer explanation available when compiling with `-explain`
    
    ```
    
    When the ID should `E001`, `EmptyCatchBlockId`. Now this correctly
    returns:
    
    ```
    scala> try {} catch{} finally {}
    -- [E001] Syntax Error: --------------------------------------------------------
    1 |try {} catch{} finally {}
      |       ^^^^^^^
      |       The catch block does not contain a valid expression, try
      |       adding a case like - case e: Exception => to the block
      |
      | longer explanation available when compiling with `-explain`
    ```
    
    The first example with the missing catch and finally block should
    actually be `[E002]`.
    ckipp01 committed Mar 26, 2022
    Configuration menu
    Copy the full SHA
    daa51df View commit details
    Browse the repository at this point in the history