Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

wgdonenotdeferred: parenthesized Done() statement escapes non-deferred detection (paren_unwrap_gap)

Aperta Adatta ai principianti
#71,337 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
devtools

Direzione di ricerca

Leggi pkg/linters/wgdonenotdeferred/wgdonenotdeferred.go in corrispondenza di inspectBody e confronta la gestione delle chiamate con i pattern di astutil.MatchDiscardedErrorCall o resourcetracker.go. Aggiungi un caso con Done() tra parentesi a testdata/src/wgdonenotdeferred/wgdonenotdeferred.go, quindi esegui i test esistenti di wgdonenotdeferred. Il lavoro è completato quando la chiamata tra parentesi non differita produce la diagnosi prevista.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

cookie sergo

Issue Type: Correctness bug (false negative) - missing ParenExpr unwrap, established paren_unwrap_gap class

Location: pkg/linters/wgdonenotdeferred/wgdonenotdeferred.go:86 (inspectBody)

Problem: The statement-level flag check does a bare type assertion with no ParenExpr unwrap first:

if call, ok := exprStmt.X.(*ast.CallExpr); ok { if isWaitGroupDone(pass, call) { ... } }

Per the Go spec ExpressionStmt grammar, function and method calls used as standalone statements may be parenthesized (the spec own example shows (<-ch) as valid). So a non-deferred call written as (wg.Done()) has exprStmt.X resolve to *ast.ParenExpr rather than *ast.CallExpr, the type assertion fails silently, and the loop moves on without ever calling isWaitGroupDone - the deadlock-risk diagnostic never fires for this exact shape, even though it is a straightforward Done() call with the exact same missing-defer bug the linter exists to catch.

Impact: Severity: medium (false negative, not false positive - a real deadlock-risk pattern is silently missed). wgdonenotdeferred is CI-enforced on BOTH native and wasm targets (.github/workflows/cgo.yml:1668 and :1695), so this gap is live in the enforced linter set, not latent. testdata/src/wgdonenotdeferred/wgdonenotdeferred.go has zero coverage of a parenthesized Done() call in either the Bad or Good fixture sections - the gap would not be caught by the existing test suite.

This is the same established pattern class already fixed in several sibling linters (closeerrorunchecked, typeassertionnil, walkdirignoredeerror, astutil.MatchDiscardedErrorCall, resourcetracker.go), applied here for the first time to wgdonenotdeferred, which had previously only been audited for the unrelated adjacent_defer_assumption and scope_boundary_funclit classes (both confirmed clean in prior runs) but never for this one.

Recommendation: Call astutil.UnwrapParenExpr(exprStmt.X) before the *ast.CallExpr assertion at line 86, mirroring the fix already applied in astutil.MatchDiscardedErrorCall and resourcetracker.go inspectNode. Add a parenthesized-call case to testdata (e.g. a BadParenthesized function with (wg.Done()) as a bare statement, expecting the same diagnostic) to lock in the fix.

Validation: Existing wgdonenotdeferred_test.go test suite plus the new parenthesized-call testdata case should both pass after the fix; no interaction expected with the loop-boundary or FuncLit-boundary logic since the fix only affects the initial type assertion.

Estimated Effort: Small (single UnwrapParenExpr call plus one testdata case).

Dedup check: gh api search/issues for wgdonenotdeferred+paren and wgdonenotdeferred alone found no prior issue describing this specific gap (only an unrelated closed refactor-clustering issue and CI-enforcement/scope-boundary issues, all already resolved).

Generated by 🤖 Sergo - Serena Go Expert · claude · agent · ~181 AIC · ⌖ ~1 AIC · ⊞ 5.4K · ◷

  • expires on Oct 29, 2026, 8:00 PM UTC-08:00
Lingua principale
Go
Stelle
5.4k
Fork
596
Merge medio
3h 40m
PR unite (30g)
830

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di github/gh-aw

Tutte le issue di github/gh-aw

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.