Skip to content

Fix internal error FS0073 w/nested inline SRTP and multiple overloads#19710

Open
gusty wants to merge 1 commit intodotnet:mainfrom
gusty:fix/srtp-unsolved-typar-codegen
Open

Fix internal error FS0073 w/nested inline SRTP and multiple overloads#19710
gusty wants to merge 1 commit intodotnet:mainfrom
gusty:fix/srtp-unsolved-typar-codegen

Conversation

@gusty
Copy link
Copy Markdown
Contributor

@gusty gusty commented May 9, 2026

Root cause: In CodegenWitnessExprForTraitConstraint, when SolveMemberConstraint resolves a trait call, FreshenMethInfo creates fresh type parameters for the method. During overload resolution, the fresh typar for a wildcard _ position gets unified with the trait call's anonymous typar, but neither gets solved to a concrete type. The solution's minst then carries these unsolved typars through GenWitnessExprBuildFSharpMethodCall → IlxGen, where they crash because the typar isn't in the TypeReprEnv.

Fix: After SolveMemberConstraint succeeds, identify any unsolved typars in the solution's minst that were freshly introduced during resolution (not present in the original trait constraint's types) and default them using ChooseTyparSolution. This ensures all type arguments in the generated expression are concrete before they reach IL codegen, without affecting typars from the calling context.

Fixes #19709

Checklist

  • Test cases added
  • Performance benchmarks added in case of performance changes
  • Release notes entry updated

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

@gusty gusty force-pushed the fix/srtp-unsolved-typar-codegen branch from 7db563d to 80b121d Compare May 9, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Internal error FS0073 "Undefined or unsolved type variable" with nested inline SRTP and multiple overloads

1 participant