The Go analysis framework allows an Analyzer to indicate that it is safe to run even in the presence of syntax and type errors, by setting RunDespiteErrors. However, the internal/checker package (used by {single,multi}checker) doesn't support it, as can be verified by running this main program:
go/analysis/passes/copylock/main.go
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ignore
// The copylock command applies the golang.org/x/tools/go/analysis/passes/copylock
// analysis to the specified packages of Go source code.
package main
import (
"golang.org/x/tools/go/analysis/passes/copylock"
"golang.org/x/tools/go/analysis/singlechecker"
)
func main() { singlechecker.Main(copylock.Analyzer) }
$ copylock -v ./...
-: # rsc.io/tmp/goplsbug
./x.go:8:31: T (type) is not an expression
./x.go:8:31: T (type) is not an expression
copylocks: 2 errors during loading
CL https://go.dev/cl/383974 purports to have added support for RunDespiteErrors, but the heuristic it uses to classify errors as typeParseError is evidently incorrect.
The Go analysis framework allows an Analyzer to indicate that it is safe to run even in the presence of syntax and type errors, by setting RunDespiteErrors. However, the
internal/checker
package (used by{single,multi}checker
) doesn't support it, as can be verified by running this main program:go/analysis/passes/copylock/main.go
on the test case in https://github.com/golang/go/issues/67787. The output is:
CL https://go.dev/cl/383974 purports to have added support for RunDespiteErrors, but the heuristic it uses to classify errors as typeParseError is evidently incorrect.
@zpavlinovic