Nest augmentation-member closures inside their declaring type under --realsig+#19955
Open
T-Gro wants to merge 6 commits into
Open
Nest augmentation-member closures inside their declaring type under --realsig+#19955T-Gro wants to merge 6 commits into
T-Gro wants to merge 6 commits into
Conversation
…-realsig+ A closure synthesized inside a member declared in an intrinsic augmentation (`type C with member ...`) was emitted as a sibling of `C` in the enclosing module class instead of nested inside `C`. Under --realsig+ a source-private member of `C` is IL `private` (type-scoped), so the sibling closure could not reach it and the CLR raised MethodAccessException at first invocation. Members declared in the type's own body were always nested correctly. GenMethodForBinding now normalizes eenv.cloc to the member's declaring type for all non-extension members under --realsig+, so the closure nests inside the type (idempotent for members that already had it). The program semantics are unchanged and the private member stays IL `private`. Fixes #19933 Co-authored-by: Copilot <[email protected]>
Contributor
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
|
Co-authored-by: Copilot <[email protected]>
…en skill The skill-and-agent validator (triggered by adding a skill) requires every agent frontmatter to declare a name; agentic-workflows.agent.md was missing it. Co-authored-by: Copilot <[email protected]>
Member
|
A possibly related issue: #5302. Maybe this kind of closures could be fixed with these changes as well. |
… shapes Adversarial review (5 models) found the original tests under-powered: runtime-only (no IL-nesting assertion, so they passed even on the buggy compiler under realsig-), the instance-member case used an inlinable private that hid the bug, and most member kinds were uncovered. - Add Regression_RealsigAugmentationClosure_StructuralAssertions.fs: under --realsig+ assert the closure nests under the declaring type (verifyILPresent "Type/closure@") and is not a module sibling (verifyILNotPresent). These FAIL on the pre-fix compiler and PASS on the fix, so they actually guard the IL shape. - Mark every private member [<NoCompilerInlining>] so the call survives the optimizer (the previous instance test guarded nothing). - Cover property getter/setter, indexer, static method, operator, seq, mutual rec, nested closures, generic method (typar threading), two-type closure-name collision, record/DU, nested-module and namespace-scoped types. Co-authored-by: Copilot <[email protected]>
…lity review)
A 5-model test-quality review found the prior tests duplicated source across two
files, used a vacuous --realsig- matrix, and reinvented framework helpers.
- Merge runtime + structural files into one MemberData-driven Theory: each shape is
asserted structurally (closure nests under the declaring type, not a module sibling)
AND run. 23 shapes as data rows + 1 --realsig- smoke (defense-in-depth only; the fix
is gated on realsig+, so realsig- IL is identical before/after).
- Add 3 shapes the review found uncovered and confirmed crash-on-shipped/fixed-on-PR:
override member, secondary constructor, struct augmentation.
- Harden the two-type and async absent-fragments against the closure-name
disambiguator ('h@N-1').
- Add an AugmentationClosureNesting.fs FileInlineData baseline (Realsig=Both) in
Inlining.fs (idiomatic EmittedIL lock) snapshotting both the realsig+ nesting
(closure nested in C, member IL private) and the realsig- lowering.
Co-authored-by: Copilot <[email protected]>
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 #19933
A closure synthesized inside a member declared in an intrinsic augmentation
(
type C with member ...) was emitted as a sibling ofCin the enclosingmodule class rather than nested inside
C. Under--realsig+a source-privatemember of
Cis ILprivate(type-scoped), so the sibling closure could notreach it and the CLR raised
MethodAccessExceptionat first invocation. Membersdeclared in the type's own body were always nested correctly.
The same placement also affected
task/asyncstate machines andquotation-splice helpers in augmentation members. Access semantics are unchanged
— the member stays IL
private; only the compiler-synthesized closure isre-homed into the declaring type, matching how members declared in the type body
already compile. The change is scoped to
--realsig+.