golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.3k stars 17.7k forks source link

cmd/go2go: build fails when using argument types from packages #39642

Closed uhthomas closed 4 years ago

uhthomas commented 4 years ago

What version of Go are you using (go version)?

https://go2goplay.golang.org/

> runtime.Version()
devel +ad307489d4 Tue Jun 16 05:49:35 2020 +0000

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

https://go2goplay.golang.org/

What did you do?

Using an argument type *url.Error results in a failed build.

See https://go2goplay.golang.org/p/A6CO8Vj3Awk

What did you expect to see?

A successful build.

What did you see instead?

panic: prog.go2:19:21: unexpected type string character '/' in "*net/url.Error"

goroutine 1 [running]:
go/go2go.(*translator).instantiatedName(0xc0004d5960, 0x0, 0xc00000c8a0, 0xc00001d050, 0x1, 0x1, 0x6da9e0, 0xc00000c740, 0xc00000c740, 0x5739f20317549601)
    /usr/local/go-faketime/src/go/go2go/names.go:61 +0x72b
go/go2go.(*translator).instantiateFunction(0xc0004d5960, 0x0, 0xc00000c8a0, 0xc00001c640, 0x1, 0x1, 0xc00001d050, 0x1, 0x1, 0xc0004d5080, ...)
    /usr/local/go-faketime/src/go/go2go/instantiate.go:94 +0x85
go/go2go.(*translator).translateFunctionInstantiation(0xc0004d5960, 0xc0000566c0)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:687 +0x3ea
go/go2go.(*translator).translateExpr(0xc0004d5960, 0xc0000566c0)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:567 +0x3e5
go/go2go.(*translator).translateExpr(0xc0004d5960, 0xc00001c670)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:572 +0x398
go/go2go.(*translator).translateExprList(0xc0004d5960, 0xc00001c670, 0x1, 0x1)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:646 +0x46
go/go2go.(*translator).translateStmt(0xc0004d5960, 0xc0000567c8)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:447 +0x29d
go/go2go.(*translator).translateStmt(0xc0004d5960, 0xc000056830)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:462 +0x3e5
go/go2go.(*translator).translateStmt(0xc0004d5960, 0xc00000cad0)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:465 +0x445
go/go2go.(*translator).translateBlockStmt(0xc0004d5960, 0xc000010de0)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:408 +0x52
go/go2go.(*translator).translateFuncDecl(0xc0004d5960, 0xc000056860)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:401 +0xc5
go/go2go.(*translator).translate(0xc0004d5960, 0xc000076200)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:329 +0x391
go/go2go.rewriteAST(0xc000056280, 0xc000056240, 0x0, 0x0, 0xc00005f680, 0xc000076200, 0x1, 0xc00005f310, 0xc00005f680)
    /usr/local/go-faketime/src/go/go2go/rewrite.go:141 +0x109
go/go2go.RewriteBuffer(0xc000056240, 0x7ffe6f323dd8, 0x1e, 0xc00012c000, 0x179, 0x379, 0x0, 0xc00008cd60, 0x40dd18, 0x30, ...)
    /usr/local/go-faketime/src/go/go2go/go2go.go:132 +0x2c5
main.translateFile(0xc000056240, 0x7ffe6f323dd8, 0x1e)
    /usr/local/go-faketime/src/cmd/go2go/translate.go:26 +0xa9
main.main()
    /usr/local/go-faketime/src/cmd/go2go/main.go:64 +0x456

Go build failed.
andybons commented 4 years ago

@griesemer @ianlancetaylor

griesemer commented 4 years ago

This is a bug in the translator part. Type-checking is fine.

gopherbot commented 4 years ago

Change https://golang.org/cl/238623 mentions this issue: [dev.go2go] go/go2go: accept slash in an instantiated type name

ianlancetaylor commented 4 years ago

Thanks. This should be fixed now.