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/text/cmd/gotext: dependency of x/tools is too old for Go 1.18 #52552

Closed
tux21b opened this issue Apr 25, 2022 · 8 comments
Closed

x/text/cmd/gotext: dependency of x/tools is too old for Go 1.18 #52552

tux21b opened this issue Apr 25, 2022 · 8 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@tux21b
Copy link
Contributor

tux21b commented Apr 25, 2022

With Go 1.18.1, it is not possible to run go run golang.org/x/text/cmd/gotext@latest extract (latest maps to v0.3.7 in this case). The problem seems to be a too old version of x/tools:

❯ go run golang.org/x/text/cmd/gotext@latest extract
panic: interface conversion: types.Type is nil, not *types.Signature

goroutine 651 [running]:
golang.org/x/tools/go/ssa.(*builder).expr0(0x7de520?, 0xc004789400, {0x8d2cf8?, 0xc0015caa20}, {0x0, {0x0, 0x0}, {0x0, 0x0}})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:679 +0x1f85
golang.org/x/tools/go/ssa.(*builder).expr(0x7dd740?, 0xc004789400, {0x8d2cf8?, 0xc0015caa20?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:530 +0x19f
golang.org/x/tools/go/ssa.(*builder).expr0(0x7de520?, 0xc004789400, {0x8d2f98?, 0xc0015c1488}, {0x2, {0x8d20a8, 0xc003a59440}, {0x0, 0x0}})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:697 +0x1abd
golang.org/x/tools/go/ssa.(*builder).expr(0x7dd740?, 0xc004789400, {0x8d2f98?, 0xc0015c1488?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:530 +0x19f
golang.org/x/tools/go/ssa.(*builder).setCallFunc(0x80?, 0xc004789400?, 0xc0015c8d00?, 0xc009b8de40)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:881 +0x2ec
golang.org/x/tools/go/ssa.(*builder).setCall(0x7de520?, 0xc004789400, 0xc0015c8d00, 0xc009b8de40)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:962 +0x31
golang.org/x/tools/go/ssa.(*builder).expr0(0x7de520?, 0xc004789400, {0x8d29f8?, 0xc0015c8d00}, {0x7, {0x8d1fb8, 0xc55a60}, {0x0, 0x0}})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:596 +0x1eae
golang.org/x/tools/go/ssa.(*builder).expr(0xc00d826da8?, 0xc004789400, {0x8d29f8?, 0xc0015c8d00?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:530 +0x19f
golang.org/x/tools/go/ssa.(*builder).assign(0xc004789400?, 0xc004789400?, {0x8d3898?, 0xc00443b0b0}, {0x8d29f8?, 0xc0015c8d00?}, 0x0?, 0xc007e910c0)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:502 +0x3db
golang.org/x/tools/go/ssa.(*builder).assignStmt(0x203002?, 0xc004789400, {0xc0015b59a0, 0x1, 0x20?}, {0xc0015b59c0, 0x1, 0x0?}, 0x1)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:1050 +0x25d
golang.org/x/tools/go/ssa.(*builder).stmt(0x0?, 0xc004789400, {0x8d2878?, 0xc0015c8d40?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2006 +0x1094
golang.org/x/tools/go/ssa.(*builder).stmtList(0xc007e91470?, 0x425a96?, {0xc0015c8e00?, 0x3, 0xc003a23840?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:790 +0x67
golang.org/x/tools/go/ssa.(*builder).stmt(0xc004789400?, 0xc004789400, {0x8d2998?, 0xc0015c39b0?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2102 +0x1331
golang.org/x/tools/go/ssa.(*builder).stmt(0x0?, 0xc004789400, {0x8d2d28?, 0xc0015c8e40?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2116 +0x17ec
golang.org/x/tools/go/ssa.(*builder).stmtList(0x0?, 0x7fb9446b0ee0?, {0xc0015b0400?, 0x24, 0x203001?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:790 +0x67
golang.org/x/tools/go/ssa.(*builder).stmt(0xc004789400?, 0xc004789400, {0x8d2998?, 0xc0015c3ec0?})
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2102 +0x1331
golang.org/x/tools/go/ssa.(*builder).buildFunction(0x7de9a0?, 0xc004789400)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2195 +0x465
golang.org/x/tools/go/ssa.(*builder).buildFuncDecl(0x7de9a0?, 0xc008b4cc60, 0xc0015c3ef0)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2225 +0x154
golang.org/x/tools/go/ssa.(*Package).build(0xc008b4cc60)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2341 +0xd05
sync.(*Once).doSlow(0x626e20?, 0xc003053800?)
        /usr/lib/go/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
        /usr/lib/go/src/sync/once.go:59
golang.org/x/tools/go/ssa.(*Package).Build(...)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2260
golang.org/x/tools/go/ssa.(*Program).Build.func1(0x25?)
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2244 +0x4c
created by golang.org/x/tools/go/ssa.(*Program).Build
        /home/christoph/go/pkg/mod/golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e/go/ssa/builder.go:2243 +0x19c
exit status 2

This bug happens on every example, even if the code does not depend on generics. One minimal example:

package main

import (
	"fmt"

	"golang.org/x/text/language"
	"golang.org/x/text/message"
)

func main() {
	p := message.NewPrinter(language.English)
	p.Printf("Hello World")
}

Explicitly depending on a newer version of x/tools in the go.mod file solves the problem for programs that do not depend on generics.

@gopherbot gopherbot added this to the Unreleased milestone Apr 25, 2022
@tux21b tux21b changed the title x/text/gotext: dependency of x/tools is too old for Go 1.18 x/text/cmd/gotext: dependency of x/tools is too old for Go 1.18 Apr 25, 2022
@tux21b
Copy link
Contributor Author

tux21b commented Apr 25, 2022

@rsc this is gotext issue 1/2

@adonovan
Copy link
Member

adonovan commented Apr 25, 2022

The panic indicates that the go/ssa package doesn't know how what to do with type parameters. There has been some very recent work by @timothy-king in that package to add support. I don't know what state it's in, but I notice that updating x/text's version of x/tools to the latest (untagged) commit does avoid the crash on these examples.

$ git diff go.mod
 module golang.org/x/text

-require golang.org/x/tools v0.1.7
+require golang.org/x/tools v0.1.11-0.20220425172941-559469ae1672
...

@tux21b
Copy link
Contributor Author

tux21b commented Apr 25, 2022

@adonovan for the example in this issue, updating to x/tools v0.1.10 is enough in my case. The newer version might help in the case with type parameters, but I have created a separate issue for that. See #52553

@gopherbot
Copy link

Change https://go.dev/cl/402254 mentions this issue: go.mod: update to golang.org/x/text v0.1.10

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 28, 2022
@cagedmantis
Copy link
Contributor

Also see #50558

@cagedmantis
Copy link
Contributor

/cc @mpvl

@yarcat
Copy link

yarcat commented Aug 9, 2022

tools@0.1.11 dependency doesn't seem enough. I still see

panic: unexpected container type in IndexExpr:  func[Topic any]() my/package/pubsub.Publisher[Topic]`

It is seems to be fixed with tools@0.1.12 though.

Unfortunately I wasn't able to reproduce this with a simple example yet.

@yarcat
Copy link

yarcat commented Aug 9, 2022

tools@0.1.12 contains a fix for #52834 which fixes exactly the issue mentioned in my previous comment

xhit pushed a commit to xhit/text that referenced this issue Oct 10, 2022
go get -u golang.org/x/tools
go mod tidy

For golang/go#50558
Fixes golang/go#52552

Change-Id: I233aa90922fc23800563fd05beb4be6f7e87cf5b
Reviewed-on: https://go-review.googlesource.com/c/text/+/402254
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
@golang golang locked and limited conversation to collaborators Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants