Skip to content

cmd/compile: internal compiler error when multiple-value result triggers an implicit conversion to an interface #78016

@eikemeier

Description

@eikemeier

The following valid program compiled until Go 1.17beta1:

package main

var a, b, c interface{} = func() (_, _, _ int) { return 1, 2, 3 }()

func main() {
	println(a.(int), b.(int), c.(int))
}

CL 327651 introduced the use of temporaries for return values of an OAS2FUNC. Consequently, when implicitly converted to an interface, these temporaries end up wrapped in an OCONVIFACE node.

Static initialization in cmd/compile/internal/staticinit/sched.go only expects OCONVNOP wrappings, resulting in an internal compiler error in Go 1.26.1:

./main.go:3:5: internal compiler error: unexpected rhs, not an autotmp: 
.   CONVIFACE Implicit INTER-interface {} tc(1) # main.go:3:5
.   .   NAME-main..autotmp_0 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used int tc(1) # main.go:3:5

The bug has existed since Go 1.17rc1, where the error message originally was: internal compiler error: unexpected package-level statement: a, b, c = .autotmp_0, .autotmp_1, .autotmp_2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions