FFFF False positive (SA4023) - 0.8.0-rc.1 · Issue #1736 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

False positive (SA4023) - 0.8.0-rc.1 #1736

Closed

Description

@mimol91
main.go:11:32: this comparison is always true (SA4023)
        main.go:11:12: the lhs of the comparison is the 1st return value of this function call
        $GOROOT/src/cmp/cmp.go:69:1: cmp.Or never returns a nil interface value

Code

package main

import (
	"cmp"
	"fmt"
)

func ok() error { return nil }

func main() {
	if err := cmp.Or(ok(), ok()); err != nil {
		fmt.Println("Error")
	}
	fmt.Println("No error")
}

This result with No error but staticcheck warns that the err is always true

     staticcheck 2026.2rc1 (0.8.0-rc.1)                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                            
     Compiled with Go version: go1.26.7                                                                                                                                                                                                                                                                                     
     Main module:                                                                                                                                                                                                                                                                                                           
        honnef.co/go/tools@v0.8.0-rc.1 (sum: h1:wqMm2kjcEXMOr+6yau+pdKqJKe6l2N1aKPkpini+Kzk=)                                                                                                                                                                                                                               
     Dependencies:                                                                                                                                                                                                                                                                                                          
        github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c (sum: h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=)                                                                                                                                                                                              
        golang.org/x/exp/typeparams@v0.0.0-20231108232855-2478ac86f678 (sum: h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=)                                                                                                                                                                                               
        golang.org/x/mod@v0.35.0 (sum: h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=)                                                                                                                                                                                                                                     
        golang.org/x/sync@v0.20.0 (sum: h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=)                                                                                                                                                                                                                                    
        golang.org/x/tools@v0.44.1-0.20260420230617-19499e7caabc (sum: h1:vSv/HN1q9eoPD7lMyJYVJ/GPYnqtqu6adMxUmrxOB78=)

Activity

  1. dominikh commented on Aug 20, 2026

    @dominikh
    Owner

    Fixed on master, will be part of the next patch release (either today or tomorrow).

  2. added a commit that references this issue on Aug 20, 2026
    4e4b914
  3. added a commit that references this issue on Aug 21, 2026
    f01b3d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0