Skip to content

cmd/go2go: panic when the type declaration is in a function scope #39643

@hajimehoshi

Description

@hajimehoshi

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

n/a

Does this issue reproduce with the latest release?

n/a

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

n/a

What did you do?

https://go2goplay.golang.org/p/FR8zgiBiF2T

package main

import (
	"fmt"
)

func main() {
	type foo(type T) T
	fmt.Printf("%T\n", foo(int)(1))
}

What did you expect to see?

Compilation succeeds

What did you see instead?

panic: parameterized type

goroutine 1 [running]:
go/go2go.(*translator).translateTypeSpec(0xc000137960, 0xc00001c3a0)
	/usr/local/go-faketime/src/go/go2go/rewrite.go:372 +0x7f
go/go2go.(*translator).translateStmt(0xc000137960, 0xc00000c3a0)
	/usr/local/go-faketime/src/go/go2go/rewrite.go:426 +0x18d
go/go2go.(*translator).translateBlockStmt(0xc000137960, 0xc000010a80)
	/usr/local/go-faketime/src/go/go2go/rewrite.go:408 +0x52
go/go2go.(*translator).translateFuncDecl(0xc000137960, 0xc00000c3f0)
	/usr/local/go-faketime/src/go/go2go/rewrite.go:401 +0xc5
go/go2go.(*translator).translate(0xc000137960, 0xc000076180)
	/usr/local/go-faketime/src/go/go2go/rewrite.go:329 +0x391
go/go2go.rewriteAST(0xc000056280, 0xc000056240, 0x0, 0x0, 0xc00005f450, 0xc000076180, 0x1, 0xc00005f310, 0xc00005f450)
	/usr/local/go-faketime/src/go/go2go/rewrite.go:141 +0x109
go/go2go.RewriteBuffer(0xc000056240, 0x7ffc42f10dd8, 0x1e, 0xc00012c000, 0x66, 0x266, 0x0, 0xc00008cd60, 0x40dd18, 0x30, ...)
	/usr/local/go-faketime/src/go/go2go/go2go.go:132 +0x2c5
main.translateFile(0xc000056240, 0x7ffc42f10dd8, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions