You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
uncheckedflushreturn: ExprStmt and AssignStmt branches do not unwrap ParenExpr, parenthesized Flush() escapes detection #71810
Linter: uncheckedflushreturn (pkg/linters/uncheckedflushreturn/uncheckedflushreturn.go), CI-enforced native+wasm (cgo.yml LINTER_FLAGS, both jobs).
Problem: Two of the three node-filter branches do a bare type assertion to *ast.CallExpr with no astutil.UnwrapParenExpr call first, and the file does not import astutil at all:
checkDiscardedFlushExpr (line 58): call, ok := stmt.X.(*ast.CallExpr)
checkDiscardedFlushAssign (line 78): call, ok := assign.Rhs[0].(*ast.CallExpr)
Only the third branch, checkDiscardedFlushDefer, is structurally immune since DeferStmt.Call is always a concrete *ast.CallExpr by Go grammar.
Impact: A parenthesized discard such as (bw.Flush()) as a bare statement, or _ = (bw.Flush()), silently escapes this CI-enforced linter, since Go allows a CallExpr to be wrapped in ParenExpr without changing its meaning. This is the same recurring paren_unwrap_gap class already fixed in several sibling linters (closeerrorunchecked, typeassertionnil, and the ExprStmt/AssignStmt dual-branch fix previously applied to astutil.MatchDiscardedErrorCall and pkg/linters/internal/resourcetracker.go).
Evidence: testdata/src/uncheckedflushreturn/uncheckedflushreturn.go has zero parenthesized-call test cases (bad/badBlankAssign/deferBad/good/suppressed/deferSuppressed all use bare unparenthesized calls).
Recommendation: Call astutil.UnwrapParenExpr on stmt.X and assign.Rhs[0] before the type assertion in both branches, matching the reference pattern already used elsewhere (e.g. uncheckedsliceindex.go, mapdeletecheck.go). Add parenthesized-call test cases to testdata for both branches.
Validation checklist:
Add (bw.Flush()) as a bare ExprStmt test case, expect diagnostic
Add _ = (bw.Flush()) test case, expect diagnostic
Existing bad/good/suppressed cases still pass unchanged
Effort: Small (2-line fix plus 2 testdata cases, isolated to one file).
Activity