Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Fixes SRTP type inference regression where curryN-style patterns worked in SDK 8.0 but failed with FS0030 (value restriction) in SDK 9.0+.

Root Cause

PR #15181 introduced FreshenTypar which clears StaticReq to None when InterfacesWithAbstractStaticMembers is enabled. SRTP typars retained their MayResolveMember constraints but lost the StaticReq marker that ApplyDefaults relied on to identify them.

Fix

Extended ApplyDefaults in CheckDeclarations.fs to explicitly check for MayResolveMember constraints:

let hasSRTPConstraint = 
    tp.Constraints |> List.exists (function TyparConstraint.MayResolveMember _ -> true | _ -> false)
    
if (tp.StaticReq <> TyparStaticReq.None) || hasSRTPConstraint then
    ChooseTyparSolutionAndSolve cenv.css denvAtEnd tp

This ensures SRTP typars are solved regardless of whether StaticReq is preserved through freshening.

Verification

  • Added regression test for curryN-style SRTP patterns
  • FSharpPlus test suite integration confirms the fix
  • No regressions in existing SRTP tests

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SRTP ApplyDefaults for TyparConstraint MayResolveMember Fix SRTP type inference regression: ApplyDefaults now solves typars with MayResolveMember constraints Jan 19, 2026
Copilot AI requested a review from T-Gro January 19, 2026 12:33
@T-Gro T-Gro closed this Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants