Skip to content

Test debug-inline capture of a local function from a nested closure - #20299

Open
T-Gro wants to merge 3 commits into
mainfrom
t-gro-fix-20297-debug-inline-captured-locals-t
Open

Test debug-inline capture of a local function from a nested closure#20299
T-Gro wants to merge 3 commits into
mainfrom
t-gro-fix-20297-debug-inline-captured-locals-t

Conversation

@T-Gro

Copy link
Copy Markdown
Member

Regression test only — #20297 is already fixed on main by #20089.

Existing coverage applies the inline function directly from the enclosing method. This test applies it inside a nested closure, so the captured local reaches the synthesized <name>__debug@N method through a closure field. Before #20089 that emitted ldarg.0; ldfld against a string parameter and crashed with AccessViolationException.

release/10.0.4xx (SDK 10.0.400) has #19548 but not #20089, and is still affected.

…callsite
Regression coverage for #20297. The reduced repro keeps the reported
shape - a captured local function, a callsite inside a nested closure,
and '>>' composition - and crashes with AccessViolationException on
release/10.0.4xx, where <addEnum>__debug@N is emitted as a two-argument
static method that does 'ldarg.0; ldfld tee' against the string
parameter. It passes once #20089 is present.
SRTP 30-38 all call the inline function directly from the enclosing
method, so none of them cover a callsite inside a closure.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actionsBot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

⚠️ Release notes required, but author opted out

Warning

Author opted out of release notes, check is disabled for this pull request.
cc @dotnet/fsharp-team-msft

@github-actionsgithub-actionsBot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Aug 19, 2026
@T-GroT-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Aug 19, 2026
@T-Gro
T-Gro requested review from abonie and auduchinokAugust 19, 2026 13:45

@auduchinokauduchinok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +1 to +6
let f () =
let tee g (x: int) = g x; x
let addName (key: string) (v: string) = tee (fun x -> printfn "%s=%s" key v)
let inline addEnum (key: string) value = tee (fun x -> printfn "%s=%d" key (x + int value))
let pipeline v = addName "a" "n" >> addEnum "b" v
pipeline 1uy 41

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally try to minimize the test, so the dumps are easier to follow if needed, but otherwise it's fine.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimized the repro in ac6ae82: dropped the printfn formatting and the extra addName closure, keeping only the essential ingredients (inline function whose body is a lambda capturing the outer local tee, used first-class inside the >> nested closure) plus the int value/ExplicitDynamic SRTP aspect. The baseline is now 108 lines (was 166) and still shows <addEnum>__debug@5 receiving the captured tee through a closure field.

@T-Gro
T-Gro enabled auto-merge (squash) August 20, 2026 11:04
Copilotand others added 2 commits August 20, 2026 13:45
Address review feedback: strip printfn and addName noise from the repro so the emitted-IL baseline is easier to follow. The minimized source keeps all essential ingredients (inline function whose body is a lambda capturing an outer local 'tee', used first-class inside a nested closure via >>) and the SRTP 'int value'/ExplicitDynamic aspect, so <addEnum>__debug@N still reaches the captured local through a closure field.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-BypassedTooling check: non-fork PR, not diff-analyzedNO_RELEASE_NOTESLabel for pull requests which signals, that user opted-out of providing release notes

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants

@T-Gro@auduchinok