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

Skip analyzers when seeing generics #324

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chressie
Copy link

@chressie chressie commented May 5, 2022

As mentioned in #323 analyzers do not yet support generics. Skip checks on code that use or depend on generic code.

chressie added 2 commits May 5, 2022 11:01
Upgrading to newest x/tools was performed with these steps:

```
% go get golang.org/x/tools@v0.1.11-0.20220504225841-45c8a7131235
% go get golang.org/x/tools/internal/gocommand@v0.1.11-0.20220504225841-45c8a7131235
% go mod download github.com/yuin/goldmark
```

With this update `interface{}` is now rendered with the new builtin type
`any`, which interfers with the golden test data in the debug/render
package. The golden files have been simply updated with the following
command:

```
% sed -i 's/interface{}/any/g' internal/pkg/debug/render/testdata/*
```

The following test fails after this upgrade:

```
% go1.18.1 test github.com/google/go-flow-levee/internal/pkg/earpointer
--- FAIL: TestMethodInvoke (0.00s)
    analysis_test.go:1212:
          got: {**T2:f.arg0}: [T1->g.t0], {*T1:f.arg0,*T2:f.t0,g.t0}: [], {*T1:f.x,*T2:f.x,g.x}: [], {*T2:f.arg0}: --> **T2:f.arg0, {*g.x2}: [T1->g.t0], {g.x2}: --> *g.x2
         want: {**T2:f.arg0}: [T1->*T1:f.arg0], {*T1:f.arg0,*T2:f.t0,g.t0}: [], {*T1:f.x,*T2:f.x,g.x}: [], {*T2:f.arg0}: --> **T2:f.arg0, {*g.x2}: [T1->*T1:f.arg0], {g.x2}: --> *g.x2
FAIL
FAIL	github.com/google/go-flow-levee/internal/pkg/earpointer	0.054s
FAIL
```

The following test panics with go1.18.1 and with this upgrade it fails:

```
% go1.18.1 test github.com/google/go-flow-levee/internal/pkg/levee
--- FAIL: TestLeveeEAR (5.97s)
    analysistest.go:455: levee_analysistest/example/tests/position/tests.go:36:11: diagnostic "a source has reached a sink\n source: /home/chressie/src/github.com/google/go-flow-levee/internal/pkg/levee/testdata/src/levee_analysistest/example/tests/position/tests.go:35:7" does not match pattern "a source has reached a sink\n source: .*tests.go:34:2"
    analysistest.go:455: levee_analysistest/example/tests/position/tests.go:42:11: diagnostic "a source has reached a sink\n source: /home/chressie/src/github.com/google/go-flow-levee/internal/pkg/levee/testdata/src/levee_analysistest/example/tests/position/tests.go:42:12" does not match pattern "a source has reached a sink\n source: .*tests.go:42:24"
    analysistest.go:519: levee_analysistest/example/tests/position/tests.go:36: no diagnostic was reported matching "a source has reached a sink\n source: .*tests.go:34:2"
    analysistest.go:519: levee_analysistest/example/tests/position/tests.go:42: no diagnostic was reported matching "a source has reached a sink\n source: .*tests.go:42:24"
--- FAIL: TestLevee (0.54s)
    analysistest.go:455: levee_analysistest/example/tests/position/tests.go:36:11: diagnostic "a source has reached a sink\n source: /home/chressie/src/github.com/google/go-flow-levee/internal/pkg/levee/testdata/src/levee_analysistest/example/tests/position/tests.go:35:7" does not match pattern "a source has reached a sink\n source: .*tests.go:34:2"
    analysistest.go:455: levee_analysistest/example/tests/position/tests.go:42:11: diagnostic "a source has reached a sink\n source: /home/chressie/src/github.com/google/go-flow-levee/internal/pkg/levee/testdata/src/levee_analysistest/example/tests/position/tests.go:42:12" does not match pattern "a source has reached a sink\n source: .*tests.go:42:24"
    analysistest.go:519: levee_analysistest/example/tests/position/tests.go:36: no diagnostic was reported matching "a source has reached a sink\n source: .*tests.go:34:2"
    analysistest.go:519: levee_analysistest/example/tests/position/tests.go:42: no diagnostic was reported matching "a source has reached a sink\n source: .*tests.go:42:24"
    analysistest.go:519: levee_analysistest/example/tests/stdlib/interface_funcs.go:45: no diagnostic was reported matching `a source has reached a sink`
FAIL
FAIL	github.com/google/go-flow-levee/internal/pkg/levee	6.870s
FAIL
```
The analyzers (or helpers that the analyzers use) currently do not
support generics. Use the `usesgenerics` analyzer from the x/tools
repository to detect usage of generics and return a synthesized empty
result in that case.

Updates google/issues/323
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant