Skip to content

dev.go2go: translator generates incorrect code for type switches, leading to duplicate cases #42758

@ghost

Description

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

$ go version
go version devel +165ceb09f9 Tue Nov 3 12:31:40 2020 -0500 windows/amd64

Does this issue reproduce with the latest release?

n/a

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

  • windows/amd64
  • go2go playground

What did you do?

https://go2goplay.golang.org/p/dTkkesE4GCX.
Error is printing when go1 compiler tries to compile translated code.
Also I ran on dev.typeparams

go tool compile -G ./issue.go

where issue.go is code from playground

Here instantiated createRequest[io.Writer] look something like:

func createRequest_ioWriter(w io.Writer) {
	switch (interface{})(w).(type) {
	case io.Writer:
		fmt.Println("W")
	case io.Writer:
		fmt.Println("io.Writer")
	}

}

What did you expect to see

An error from go2go like type parameter cannot be case of type switch.

What did you see instead?

Code passes go2go and dev.typeparams type checker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone 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