Skip to content

cmd/compile: type assertion on generic type fails incorrectly #53309

Closed
@heschi

Description

@heschi

The following program panics for no reason I can discern:

package workflow

import (
	"fmt"
	"testing"
)

type TaskInput interface {
	deps() []*taskDefinition
}

type Value[T any] interface {
	metaValue
}

type metaValue interface {
	TaskInput
}

type taskDefinition struct {
}

type taskResult struct {
	task *taskDefinition
}

func (tr *taskResult) deps() []*taskDefinition {
	return nil
}

func TestTrivial(t *testing.T) {
	tr := &taskResult{&taskDefinition{}}
	use(Value[string](tr))
}


func use[T any](v Value[T]) {
	_, ok := v.(*taskResult)
	if !ok {
		panic(fmt.Errorf("output must be a task result, is %T", v))
	}
}

cc @golang/runtime

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions