Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#71,337 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
devtools

Research direction

Read pkg/linters/wgdonenotdeferred/wgdonenotdeferred.go at inspectBody and compare its call handling with the referenced astutil.MatchDiscardedErrorCall or resourcetracker.go patterns. Add a parenthesized Done() case to testdata/src/wgdonenotdeferred/wgdonenotdeferred.go, then run the existing wgdonenotdeferred tests. Done means the parenthesized non-deferred call produces the expected diagnostic.

Written by the indexing model from the issue text.

Description

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
Dominant language
Go
Stars
5.4k
Forks
596
Avg merge
3h 40m
Merged PRs (30d)
830

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/gh-aw

All issues in github/gh-aw

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.