Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The specification is quite clear that any name defined a catch statement will do nothing more than shadow a surrounding name. Beyond that I would not consider these errors as nothing more than a warning. Just using pure intuition I believe that this is simply overzealous analysis on the part of the designer of those Lint tools. </p> <p>Since a catch block introduces a new scope, using the same name will simply shadow any similar names in the enclosing scope. This isn't necessarily a bad thing if you are aware of the semantics. If you are coding under the assumption that the enclosing <code>err</code> will be accessible than you'll need to change your assumptions.</p> <p><strong>Specification</strong></p> <p>The production Catch : catch ( Identifier ) Block is evaluated as follows:</p> <ol> <li>Let C be the parameter that has been passed to this production.</li> <li>Let oldEnv be the running execution context’s LexicalEnvironment.</li> <li>Let catchEnv be the result of calling NewDeclarativeEnvironment passing oldEnv as the argument.</li> <li>Call the CreateMutableBinding concrete method of catchEnv passing the Identifier String value as the argument.</li> <li>Call the SetMutableBinding concrete method of catchEnv passing the Identifier, C, and false as arguments. Note that the last argument is immaterial in this situation.</li> <li>Set the running execution context’s LexicalEnvironment to catchEnv.</li> <li>Let B be the result of evaluating Block.</li> <li>Set the running execution context’s LexicalEnvironment to oldEnv.</li> <li>Return B.</li> </ol> <p><strong>NOTE</strong> No matter how control leaves the Block the LexicalEnvironment is always restored to its former state.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload