Skip to content

@alwaysThrows doesn't play nice with case_block_not_terminated #34048

Open
@nex3

Description

@nex3

The analyzer won't allow a function annotated with @alwaysThrows as the final statement in a case. However, it also considers code after it to be dead. For example:

import 'package:meta/meta.dart';

@alwaysThrows
void thrower() {
  throw "dang";
}

void doIt() {
  switch ("foo") {
    case "foo":
      thrower();

    case "bar":
      thrower();
      return null;
  }
}

This produces one error and one hint:

Analyzing test.dart...
  error • The last statement of the 'case' should be 'break', 'continue', 'rethrow', 'return' or 'throw' at test.dart:10:5 • case_block_not_terminated                                                 
  hint • Dead code at test.dart:15:7 • dead_code
1 error and 1 hint found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.customer-dart-sassdevexp-warningIssues with the analyzer's Warning codestype-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