Skip to content

cmd/compile: type inference should look inside type parameters #49575

@griesemer

Description

@griesemer

This is extracted from issue #49441.

For

package p

func f[T any, PT *T](x PT) {}

func _[T any, PT *T](x PT) {
        f(x)
}

we currently get an error (at the wrong line, see issue #45985 for that).

But the question arises, should we be able to infer the type arguments in this case?

@hanchaoqun has provided CL 362776 (thanks!) that addresses this and would make this code work.

Need to decide a) if we want this; and b) is the CL correct (are there unintended consequences).

cc @ianlancetaylor for thoughts on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.TypeInferenceIssue is related to generic type inferencegenericsIssue is related to generics

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions