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

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

Closed
hajimehoshi opened this issue Jun 17, 2020 · 4 comments
Closed

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

hajimehoshi opened this issue Jun 17, 2020 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@hajimehoshi
Copy link
Member

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
@andybons
Copy link
Member

@griesemer @ianlancetaylor

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 17, 2020
@andybons andybons added this to the Unplanned milestone Jun 17, 2020
@griesemer griesemer modified the milestones: Unplanned, Unreleased Jun 17, 2020
@gopherbot
Copy link

Change https://golang.org/cl/238619 mentions this issue: [dev.go2go] go/go2go: error, not panic, for local parameterized type

@gopherbot
Copy link

Change https://golang.org/cl/238620 mentions this issue: [dev.go2go] cmd/go2go: document that function-local parameterized types don't work

@ianlancetaylor
Copy link
Contributor

Thanks for the test case. The translation tool does not support function-local parameterized types. It will now give an error message rather than panicking.

gopherbot pushed a commit that referenced this issue Jun 17, 2020
Fixes #39643

Change-Id: I45aaaf8818d4d383d1514891b5cc9bc68926ad97
Reviewed-on: https://go-review.googlesource.com/c/go/+/238619
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue Jun 17, 2020
…es don't work

For #39643

Change-Id: Ic3d3e4a4bd46c62705d3ce3473e3e06e1380d834
Reviewed-on: https://go-review.googlesource.com/c/go/+/238620
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Jun 17, 2021
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