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

Panic on formatting of multiple files #269

Open
pavelmemory opened this issue Apr 14, 2023 · 0 comments
Open

Panic on formatting of multiple files #269

pavelmemory opened this issue Apr 14, 2023 · 0 comments

Comments

@pavelmemory
Copy link

Machine:
OS: Ubuntu 20.04.6 LTS
Version: 20.04.6 LTS (Focal Fossa)
Architecture: x86-64
Go: go version go1.20.2 linux/amd64

While running the tool on top of the generated code which is completely valid the panic occurs.
Can't be reproduced on a single file, only happens if there are multiple files passed to the tool.
The command from the Makefile looks like: gofumpt -extra -l -w $(shell find . -name "*.go")

panic: invalid line number 110 (should be < 110) [recovered]
        panic: invalid line number 110 (should be < 110)

goroutine 6482 [running]:
golang.org/x/tools/go/ast/astutil.Apply.func1()
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:48 +0xb4
panic({0x66aba0, 0xc002a5eee0})
        /home/pavlo/go/src/runtime/panic.go:884 +0x213
go/token.(*File).MergeLine(0xc0042123c0, 0x1?)
        /home/pavlo/go/src/go/token/position.go:151 +0x1ee
mvdan.cc/gofumpt/format.(*fumpter).removeLines(...)
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/format/format.go:248
mvdan.cc/gofumpt/format.(*fumpter).removeLinesBetween(0xc0003d6280, 0xc0007027c0?, 0x14d1?)
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/format/format.go:256 +0x155
mvdan.cc/gofumpt/format.(*fumpter).applyPre(0xc0003d6280, 0xc0016c4790)
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/format/format.go:543 +0x7d1
mvdan.cc/gofumpt/format.File.func1(0xc0016c4790)
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/format/format.go:109 +0x3a
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0016c4780, {0x70df88?, 0xc000465000?}, {0x6b3eef?, 0x0?}, 0x0?, {0x70dbc8?, 0xc000386420?})
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:199 +0x202
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0016c4780, {0x70dbc8?, 0xc0005383c0?}, {0x6b3f3b?, 0x1?}, 0x1?, {0x70df88?, 0xc000465000?})
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:358 +0x16dd
golang.org/x/tools/go/ast/astutil.(*application).applyList(0xc0016c4780, {0x70dbc8?, 0xc0005383c0}, {0x6b3f3b, 0x4})
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:484 +0xb1
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0016c4780, {0x70de98?, 0xc0005383f0?}, {0x6b3eef?, 0x0?}, 0x0?, {0x70dbc8?, 0xc0005383c0?})
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:353 +0x15d6
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0016c4780, {0x70de48?, 0xc0000a8120?}, {0x6b4153?, 0x70d7f8?}, 0x0?, {0x70de98?, 0xc0005383f0?})
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:429 +0x2287
golang.org/x/tools/go/ast/astutil.(*application).applyList(0xc0016c4780, {0x70de48?, 0xc0000a8120}, {0x6b4153, 0x5})
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:484 +0xb1
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0016c4780, {0x70e640?, 0xc000152f80?}, {0x6b3f53?, 0x68e740?}, 0xc001055cb0?, {0x70de48?, 0xc0000a8120?})
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:435 +0x232e
golang.org/x/tools/go/ast/astutil.Apply({0x70de48?, 0xc0000a8120}, 0xc000307878, 0xc000307890)
        /home/pavlo/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:53 +0x166
mvdan.cc/gofumpt/format.File(0xc000436040, 0xc0000a8120, {{0xc0002df0b8, 0x5}, {0xc000be6da0, 0x8}, 0x1})
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/format/format.go:157 +0x2ed
main.processFile({0x7ffe8062bfb0, 0x3f}, {0x70fa28, 0xc00010eb60}, {0x0?, 0x0?}, 0xc004212840?, 0x1)
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:313 +0x318
main.gofmtMain.func3(0xc0001c77a0?)
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:508 +0x3a
main.(*sequencer).Add.func2()
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:191 +0x45
created by main.(*sequencer).Add
        /home/pavlo/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:190 +0x1b3
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

No branches or pull requests

1 participant