Skip to content

coverage false positives for structural lines like } finally { #2241

@DanTup

Description

@DanTup

A PR was raised at Dart-Code/Dart-Code#5769 to work around this issue in Dart-Code, but I think it would be better to resolve the problem in the source data here.

Original description from @tcf909:


Description

This PR fixes false positive coverage reporting for structural lines like } finally { that are incorrectly shown as uncovered in VS Code's coverage visualization.

Problem

The Dart VM incorrectly generates branch coverage entries (BRDA) for structural lines like } finally { without corresponding line coverage entries (DA). This causes the extension to mark these lines as coverable but uncovered, resulting in:

  • Red gutter markers on structural lines
  • Coverage showing < 100% even when all executable code is covered

Example

try {
  // code
} finally {  // ← Line incorrectly shown as uncovered
  cleanup();
}

lcov.info data:

DA:227,1    (line before finally - covered)
BRDA:229,0,0,0  (} finally { - spurious entry!)
DA:230,1    (first line in finally - covered)

Related Issues

Similar to dart-lang/sdk#31222 which fixed async function closing brace coverage issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions