Skip to content

go/types: cannot infer type arguments in self-recursive call (stack overflow in unification) #51158

Closed
@griesemer

Description

@griesemer

This is a follow-up on #50755. The following code:

func f[M map[K]int, K comparable](m M) {
        f(m)
}

leads to an internal stack overflow during unification and then type checking fails with error:

M does not match map[K]int

Start of the inference process:

-- inferA [M₁, K₂] -> []
M₁ ≡ M₁
.  M₁ ➞ M₁
-- inferB [M₁, K₂] ➞ [M₁, <nil>]
M₁ ➞ M₁
M₁ ≡ map[K₂]int
.  M₁ ≡ map[K₂]int
.  .  M₁ ≡ map[K₂]int
.  .  .  M₁ ≡ map[K₂]int
.  .  .  .  M₁ ≡ map[K₂]int
etc.

Marking for 1.18 in case the fix is easy. Ok to move to 1.19.

cc: @findleyr

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