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

jsonnet-lint panics on an import that imports the same file #544

Open
gotwarlost opened this issue Jun 25, 2021 · 2 comments · May be fixed by #548
Open

jsonnet-lint panics on an import that imports the same file #544

gotwarlost opened this issue Jun 25, 2021 · 2 comments · May be fixed by #548

Comments

@gotwarlost
Copy link
Contributor

gotwarlost commented Jun 25, 2021

One of our files had an unused variable that was set to an import of the same file.

$ cat tmp/foo.libsonnet
local foo = import 'foo.libsonnet';
{}

$ jsonnet-lint tmp/foo.libsonnet
tmp/foo.libsonnet:1:7-35 Unused variable: foo

local foo = import 'foo.libsonnet';


panic: Bug - placeholder for a dependent node cannot be noType

goroutine 1 [running]:
github.com/google/go-jsonnet/linter/internal/types.(*typeGraph).getExprPlaceholder(...)
        /go/go-jsonnet/linter/internal/types/build_graph.go:26
github.com/google/go-jsonnet/linter/internal/types.calcTP(0x1200cc0, 0xc00010a100, 0xc00005f440, 0xc0001246c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /go/go-jsonnet/linter/internal/types/build_graph.go:217 +0x3696
github.com/google/go-jsonnet/linter/internal/types.prepareTPWithPlaceholder(0x1200cc0, 0xc00010a100, 0xc00005f440, 0xc0001246c0, 0x72)
        /go/go-jsonnet/linter/internal/types/build_graph.go:86 +0x179
github.com/google/go-jsonnet/linter/internal/types.prepareTPWithPlaceholder(0x1200fc0, 0xc000104280, 0xc00005f440, 0xc0001246c0, 0x71)
        /go/go-jsonnet/linter/internal/types/build_graph.go:62 +0xb2b
github.com/google/go-jsonnet/linter/internal/types.(*typeGraph).addRoots(0xc0001246c0, 0xc0001df698, 0xc0001df5d8)
        /go/go-jsonnet/linter/internal/types/build_graph.go:96 +0x3ee
github.com/google/go-jsonnet/linter/internal/types.Check(0x1200fc0, 0xc000104280, 0xc0001df698, 0xc0001df5d8, 0xc00004a7e0, 0xc0001df5c0)
        /go/go-jsonnet/linter/internal/types/check.go:139 +0xb4
github.com/google/go-jsonnet/linter.lint(0xc00005c0a0, 0x1200fc0, 0xc000104280, 0x7ffeefbff02d, 0x11, 0xc0001dfdb0)
        /go/go-jsonnet/linter/linter.go:76 +0x8a4
github.com/google/go-jsonnet/linter.LintSnippet(0xc00005c0a0, 0x11fd6c0, 0xc00000e020, 0x7ffeefbff02d, 0x11, 0xc00001c360, 0x27, 0xc000104140)
        /go/go-jsonnet/linter/linter.go:134 +0x13d
main.main()
        /go/go-jsonnet/cmd/jsonnet-lint/cmd.go:187 +0x84a
@sbarzowski
Copy link
Collaborator

Thanks for reporting. I'll send any updates here.

@SergioSim
Copy link

The same error happens when linting two dependent files at the same time.
Example:

$ cat tmp/foo.jsonnet
local bar = import 'bar.libsonnet';
{}

$ cat tmp/bar.libsonnet
{}

$ jsonnet-lint tmp/bar.libsonnet tmp/foo.jsonnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants