Skip to content

checker: fix generic type resolution in struct init with $if T is Type (fix #24471)#26593

Draft
kbkpbot wants to merge 2 commits intovlang:masterfrom
kbkpbot:fix-issue-24471
Draft

checker: fix generic type resolution in struct init with $if T is Type (fix #24471)#26593
kbkpbot wants to merge 2 commits intovlang:masterfrom
kbkpbot:fix-issue-24471

Conversation

@kbkpbot
Copy link
Contributor

@kbkpbot kbkpbot commented Feb 12, 2026

fix #24471)

When a generic method returns a generic struct initialized inside a $if T is Type branch, the compiler incorrectly resolved the function's generic parameter T using the struct init's concrete types instead of the function's concrete types.

Example that failed before:

  fn (thing GenericThing[T]) weird() AnotherGenericThing[int] {
      $if T is Type2 {
          return AnotherGenericThing[int]{thing.part1.item}  // error: int has no property item
      }
  }

The fix reorders the priority in unwrap_generic(): function-level generic parameters are now resolved before struct init context.

@kbkpbot kbkpbot marked this pull request as draft February 13, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generics compile failure

1 participant