Skip to content

cmd/compile: typeparams: ++ operator doesn't instantiate correctly #47258

@randall77

Description

@randall77
package main

type C interface {
	int32
}

func inc[T C](x T) T {
	x++
	return x
}
func main() {
	println(inc(int32(5)))
}

$ go run -gcflags=-G=3 ~/gowork/tmp2.go
# command-line-arguments
../../../gowork/tmp2.go:8:3: invalid operation: x + 1 (mismatched types int32 and int)
../../../gowork/tmp2.go:12:13: invalid operation: x + 1 (mismatched types int32 and int)

I think the 1 introduced by ++ needs to have the type of the LHS.

Not sure why there are two errors also.

@danscales

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions