Skip to content

[Wildcard Variables] Update UNUSED_CATCH_CLAUSE reporting #55723

@pq

Description

@pq

Like UNUSED_LOCAL_VARIABLEs (#55719), UNUSED_CATCH_CLAUSE should not special case __s.

This adjustment is straight-forward in the presence of an on clause where __s are special cased, however the case without an on is interesting... Currently we do not report unused catch clauses if there is no on clause regardless of underscores.

For example:

try {
} catch(e) { }

is treated the same as

try {
} catch(_) { }

(And neither produce a diagnostic.)

Question: with wildcard variables, should we start reporting UNUSED_CATCH_CLAUSE on all bound variables (and so on the catch(e) case above)?

(Note that this will be a bit disruptive -- luckily the quick fix is easy to implement.)

/cc @kallentu @bwilkerson @munificent

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-warningIssues with the analyzer's Warning codesfeature-wildcard-variablesImplementation of the wildcard variables featuretype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions