Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/go/analysis/internal/checker: support RunDespiteErrors #67790

Closed
adonovan opened this issue Jun 3, 2024 · 1 comment
Closed

x/tools/go/analysis/internal/checker: support RunDespiteErrors #67790

adonovan opened this issue Jun 3, 2024 · 1 comment
Assignees
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Jun 3, 2024

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) }

on the test case in #67787. The output is:

$ 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.

@zpavlinovic

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jun 3, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jun 3, 2024
@adonovan adonovan added Analysis Issues related to static analysis (vet, x/tools/go/analysis) and removed Tools This label describes issues relating to any tools in the x/tools repository. labels Jun 3, 2024
@mknyszek mknyszek added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 3, 2024
@zpavlinovic zpavlinovic self-assigned this Jun 4, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/591117 mentions this issue: internal/checker: run despite all errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants