Skip to content

cmd/compile: cannot convert untyped string value to type parameter constrained by ~string | ~[]byte #51386

@dominikh

Description

@dominikh

Input:

package pkg

func foo[T ~string | ~[]byte]() {
	var _ T = T("")
}

Output:

./baz.go:4:14: cannot convert "" (untyped string value) to type T:
	cannot convert "" (untyped string constant) to []byte (in T)

I expected this conversion to work. If it isn't supposed to work, then the error message is confusing.

/cc @griesemer

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