Skip to content

Handle labeled previous statements in cuddle checks to avoid false positives on if - #277

Merged
bombsimon merged 3 commits into
mainfrom
copilot/fix-false-positive-reports
Aug 9, 2026
Merged

Handle labeled previous statements in cuddle checks to avoid false positives on if#277
bombsimon merged 3 commits into
mainfrom
copilot/fix-false-positive-reports

Conversation

Copilot AI commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

wsl could incorrectly report missing whitespace above this line (invalid statement above if) when an if followed a labeled statement, even when the labeled statement wrapped a valid assignment. The check was evaluating *ast.LabeledStmt directly instead of the underlying statement kind.

  • Parser logic: unwrap labeled statements before validation

    • Added unlabeledStmt(ast.Node) ast.Node to peel nested *ast.LabeledStmt wrappers.
    • Updated cuddle/type validation path to use the unwrapped previous statement when checking allowed previous statement types and identifier intersection.
  • Behavioral coverage: labeled assignment above if

    • Added focused testdata in default_config/if for a loop label followed by err := ... and if err != nil, asserting no false-positive whitespace diagnostic.
for {
LABEL:
    _, err := fn()
    if err != nil {
        goto LABEL
    }
}

Copilot AI linked an issue Aug 8, 2026 that may be closed by this pull request
Co-authored-by: bombsimon <3248948+bombsimon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix false-positive reports for labeled statements Handle labeled previous statements in cuddle checks to avoid false positives on if Aug 8, 2026
Copilot AI requested a review from bombsimon August 8, 2026 11:36
Comment thread wsl.go
Co-authored-by: bombsimon <3248948+bombsimon@users.noreply.github.com>
Copilot AI requested a review from bombsimon August 8, 2026 11:43
@bombsimon
bombsimon marked this pull request as ready for review August 9, 2026 08:54
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.644% (+0.03%) from 94.618% — copilot/fix-false-positive-reports into main

@bombsimon
bombsimon merged commit d85ac37 into main Aug 9, 2026
5 checks passed
@bombsimon
bombsimon deleted the copilot/fix-false-positive-reports branch August 9, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False-positive reports for labeled statements

3 participants