Coder Social home page Coder Social logo

Comments (2)

flimzy avatar flimzy commented on July 23, 2024

Similar panic in the stdlib on this file, although this one appears to be intentionally "broken" (not sure if that means gofumpt should actually panic, though):

$ gofumpt -w test/dwarf/linedirectives.go 
panic: invalid line number 289 (should be < 83) [recovered]
        panic: invalid line number 289 (should be < 83)

goroutine 19 [running]:
golang.org/x/tools/go/ast/astutil.Apply.func1()
        /home/jonhall/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:48 +0xab
panic({0x66f1e0?, 0xc0001143d0?})
        /usr/local/go/src/runtime/panic.go:914 +0x21f
go/token.(*File).MergeLine(0xc000134480, 0xc000112a48?)
        /usr/local/go/src/go/token/position.go:152 +0x1c8
mvdan.cc/gofumpt/format.(*fumpter).removeLines(...)
        /home/jonhall/src/gofumpt/format/format.go:249
mvdan.cc/gofumpt/format.(*fumpter).removeLinesBetween(0xc0001320a0, 0xc00015c200?, 0x5b8?)
        /home/jonhall/src/gofumpt/format/format.go:257 +0x13f
mvdan.cc/gofumpt/format.(*fumpter).applyPre(0xc0001320a0, 0xc0001344f0)
        /home/jonhall/src/gofumpt/format/format.go:545 +0x7b2
mvdan.cc/gofumpt/format.File.func1(0xc0001344f0)
        /home/jonhall/src/gofumpt/format/format.go:109 +0x34
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0001344e0, {0x724050?, 0xc00011a420?}, {0x6bf529?, 0x0?}, 0x0?, {0x723998?, 0xc00011a3f0?})
        /home/jonhall/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:199 +0x1aa
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0001344e0, {0x724078?, 0xc0001520a0?}, {0x6bf95e?, 0x40d1da?}, 0x14?, {0x724050?, 0xc00011a420?})
        /home/jonhall/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:429 +0x225d
golang.org/x/tools/go/ast/astutil.(*application).applyList(0xc0001344e0, {0x724078?, 0xc0001520a0}, {0x6bf95e, 0x5})
        /home/jonhall/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:484 +0xa5
golang.org/x/tools/go/ast/astutil.(*application).apply(0xc0001344e0, {0x7242d8?, 0xc0001143a0?}, {0x6bf699?, 0x697fe0?}, 0x6b7040?, {0x724078?, 0xc0001520a0?})
        /home/jonhall/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:435 +0x230e
golang.org/x/tools/go/ast/astutil.Apply({0x724078?, 0xc0001520a0}, 0xc000128b58, 0xc000128b70)
        /home/jonhall/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:53 +0x152
mvdan.cc/gofumpt/format.File(0xc000116080, 0xc0001520a0, {{0x6bf2e6, 0x2}, {0x0, 0x0}, 0x0})
        /home/jonhall/src/gofumpt/format/format.go:157 +0x2d7
main.processFile({0x7ffd6c1f2e83, 0x1c}, {0x725828, 0xc0000964e0}, {0x0?, 0x0?}, 0x0?, 0x1)
        /home/jonhall/src/gofumpt/gofmt.go:313 +0x308
main.gofmtMain.func3(0x0?)
        /home/jonhall/src/gofumpt/gofmt.go:508 +0x34
main.(*sequencer).Add.func2()
        /home/jonhall/src/gofumpt/gofmt.go:191 +0x42
created by main.(*sequencer).Add in goroutine 1
        /home/jonhall/src/gofumpt/gofmt.go:190 +0x1ae

from gofumpt.

mvdan avatar mvdan commented on July 23, 2024

Thanks for spotting - I've never liked those line directives to be honest. They are definitely an obstacle for a formatter.

from gofumpt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.