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

[wildcards] Consider quick fix: convert UNUSED_CATCH_STACK to wildcard #56582

Closed
Tracked by #55681
pq opened this issue Aug 27, 2024 · 3 comments
Closed
Tracked by #55681

[wildcards] Consider quick fix: convert UNUSED_CATCH_STACK to wildcard #56582

pq opened this issue Aug 27, 2024 · 3 comments
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-wildcard-variables Implementation of the wildcard variables feature P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug type-question A question about expected behavior or functionality

Comments

@pq
Copy link
Member

pq commented Aug 27, 2024

Given:

f() {
  try {
  } on String catch (e, stackTrace) {
    print(e);
  }
}

we might consider a fix that produces:

f() {
  try {
  } on String catch (e, _) {
    print(e);
  }
}

in addition to the one that currently removes the unused clause:

f() {
  try {
  } on String catch (e) {
    print(e);
  }
}

Question: is there value in adding a convert UNUSED_CATCH_STACK to a wildcard fix?

@kallentu @bwilkerson

@dart-github-bot
Copy link
Collaborator

Summary: The issue proposes a quick fix to convert the UNUSED_CATCH_STACK lint to a wildcard, which would simplify the lint's implementation and potentially improve performance.

@dart-github-bot dart-github-bot added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug labels Aug 27, 2024
@pq pq added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-quick-fix feature-wildcard-variables Implementation of the wildcard variables feature P2 A bug or feature request we're likely to work on type-question A question about expected behavior or functionality and removed area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Aug 27, 2024
@pq pq changed the title Quick fix: convert UNUSED_CATCH_STACK to wildcard [wildcards] Consider quick fix: convert UNUSED_CATCH_STACK to wildcard Aug 27, 2024
@bwilkerson
Copy link
Member

I don't see any value in having a wildcard in a non-required location. While the language makes it valid (presumably for consistency), I wouldn't want to see it in my code. (I'd actually want an unnecessary_stack_trace_parameter (or some such) warning.

The only time I'd allow a wildcard is for something like

f() {
  try {
  } on String catch (_, stackTrace) {
    print(stackTrace);
  }
}

where the exception isn't used but has to be provided in order to capture the stack trace.

If we had a warning when the exception parameter isn't referenced (which we don't have but might consider adding now) we could have a fix to convert it to a wildcard.

@pq
Copy link
Member Author

pq commented Aug 27, 2024

Great. Agreed. Thanks!

@pq pq closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-wildcard-variables Implementation of the wildcard variables feature P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

3 participants