Fix FS0192 Iterate2D from ReflectedDefinition over a recursive value - #20488
Open
T-Gro wants to merge 5 commits into
Open
Fix FS0192 Iterate2D from ReflectedDefinition over a recursive value#20488T-Gro wants to merge 5 commits into
T-Gro wants to merge 5 commits into
Conversation
…ric recursion ICE) Adds three failing ComponentTests proving the FS0192 'internal error: Iterate2D' crash when [<ReflectedDefinition(true)>] on a parameter is used from an inferred generically-recursive function. No compiler source changed; a later sprint fixes it. Includes red-evidence-sprint01.txt showing all three tests failing with Iterate2D. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A [<ReflectedDefinition(true)>] parameter auto-quotes its argument via Expr.WithValue (mkCallLiftValueWithDefn), which copies the argument with copyExpr. copyExpr inlines Expr.Link fixup nodes at copy time, so a use of an inferred generically-recursive function captured in the argument was snapshotted before AdjustAndForgetUsesOfRecValue inserted the generalized type arguments at the letrec point. The detached snapshot kept zero type arguments while the value had formal typars, so GetWitnessArgs' Iterate2D zip failed with FS0192. The auto-quote copy now uses copyExprKeepingRecursiveValLinks, which keeps a fresh Expr.Link pointing at the original recursive-use fixup node (only for values still in their letrec scope) so the quoted copy receives the same inferred type arguments as the executable expression. Both Quote true and Quote false conversions are unaffected for non-recursive uses, and FS1230 for inner generic functions in quotations still fires. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… 20379 Broaden regression coverage for the FS0192 (Iterate2D) fix: mutual recursion, nested lambdas/captures/shadowing, static and instance attributed methods, cross-assembly attributed API, single-evaluation of the auto-quoted argument, controls (false-attribute/nonrecursive/ordinary/explicit-quotation/monomorphic/ explicit-generic), and preservation of FS1230 for inner generic functions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…20379) Expert-review hardening: isRecursiveValFixupLink now matches only the exact fixup shape Expr.App(Expr.Val _, _, _, [], _) with empty value args, matching what AdjustAndForgetUsesOfRecValue accepts. Strictly more precise; no behavior change for the sole Remap.Empty/CloneAll auto-quote caller. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The isRecursiveValFixupLink predicate over-matched monomorphic recursive data values (lazy-initialized 'let rec'). Such a value's shared fixup node is re-mutated to a lazy 'Force' by EliminateInitializationGraphs, so keeping a link to it leaked a 'Force(ValueWithName ...)' node into the auto-quoted (WithValue) definition. Only function-valued recursive bindings benefit from link preservation and are bound as lambdas (never lazy-morphed), so restrict the predicate to values whose ValReprInfo has curried arguments. Adds a monomorphic-recursive-data-value regression test asserting no lazy Force leaks into the captured quotation. Also removes a stray committed red-evidence log artifact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
Warning No PR link found in some release notes, please consider adding it.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20379
A
[<ReflectedDefinition(true)>]parameter that auto-quotes an argument capturing a not-yet-generalized use of an inferred generically-recursive function triggered internal error FS0192 "Iterate2D". The auto-quoted (Expr.WithValue) copy now keeps a fresh link to the recursive-value use, so it receives the same inferred type arguments that are applied at the letrec point as the executable expression.