Repository navigation
Diagnose or hoist NativePtr.stackalloc where localloc is invalid IL - #20491
Conversation
NativePtr.stackalloc emits the 'localloc' IL instruction, which the JIT rejects inside an exception-handling region, causing InvalidProgramException at method load. Detect this during PostInferenceChecks and emit compile-time error FS3916 when stackalloc is applied inside a 'with' handler or 'finally' block. A withinHandler env flag is set on the handler/finally bodies and reset at closure and method boundaries so stackalloc in a lambda or object-expression method defined in a handler stays legal. Part of issue #20295 (Case 1). Co-authored-by: Copilot <[email protected]>
…FS3916) An immediately-applied lambda in a 'try' handler is inlined into the handler's IL region by the optimizer, so its 'localloc' still lands inside the exception-handling region and throws InvalidProgramException under --optimize+. The CheckLambdas 'withinHandler = false' reset was based on the false premise that every lambda becomes a separate method; remove it so lambda bodies inside a handler are conservatively checked. Genuine method boundaries (object-expression/interface methods) keep their reset via CheckMethod and remain legal (verified by compileExeAndRun). Part of issue #20295 (Case 1). Co-authored-by: Copilot <[email protected]>
… Case 2) NativePtr.stackalloc used as a chained base-constructor argument emitted 'localloc' while an uninitialized 'this' was pending on the evaluation stack, which the JIT rejects (InvalidProgramException at method load). The uninitialized 'this' cannot be spilled to a local, so the existing spill mechanism could not clear the stack. When a base/self-ctor argument may emit 'localloc', evaluate the arguments into locals first (at a clean stack), then push 'this' and reload them. Left-to-right evaluation order is preserved and ordinary base ctors emit byte-identical IL. The fix is applied in both GenApp and GenILCall. Co-authored-by: Copilot <[email protected]>
…0295) Co-authored-by: Copilot <[email protected]>
Adds a Fixed release note for the Case-2 base-constructor argument hoist. Verified xlf/surface-area baselines are in sync and formatting is clean; ran full regression (NativeInterop 17/17, Byref 138/138, Language RegressionTests 29/29, SurfaceAreaTest green). Co-authored-by: Copilot <[email protected]>
…20295 Case 1) The syntactic PostInferenceChecks detection ran before inlining and closure conversion, so it could not tell an escaping closure (whose 'localloc' lands in its own method and is legal) from an inlined/immediately-applied lambda or a 'let inline' wrapper (whose 'localloc' lands in the handler region and is illegal). This produced both a false positive (rejecting legal escaping closures) and a false negative ('let inline' wrapper compiled and threw InvalidProgramException at load). Detect 'localloc' emission inside a catch/filter/finally/fault region at codegen instead, via a new eenv.withinExnHandler flag set on the handler bodies in GenTryWith/GenTryFinally and reset at method/closure boundaries. By that point inlining and closure conversion have run, so the true exception-handling region is known: escaping closures stay legal, inlined localloc is rejected. The try body keeps 'localloc' legal per ECMA-335. Removes the now-unused withinHandler plumbing and the nativeptr_stackalloc_vref intrinsic. Co-authored-by: Copilot <[email protected]>
…20295) The prior commit's test edit stripped the [<Fact>] let header, orphaning the try-body assertion inside the escaping-closure test and breaking the ComponentTests build with FS0020. Restore it as its own Fact. Co-authored-by: Copilot <[email protected]>
✅ No release notes required |
Co-authored-by: Copilot <[email protected]>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <[email protected]> Copilot-Session: 457e0e99-9880-4692-aed5-6ebcf92c9e43
…20342) * Order explicit type args by constraint dependencies before unifying A generic value/method with a subtype constraint that references a later type parameter (Register<'a,'b when 'a :> I<'b>>) failed with FS0001 when the argument implements the interface at several instantiations. The explicit type arguments are now unified in dependency order so a parameter referenced by another's constraint is solved first. Fixes #20103 Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8ce30fb9-238f-4bb2-8f31-71e8d173c2ca * Address review feedback Add equal-arity competing overloads with explicit selection assertions and explicit/inferred type arguments. Verify dependency ordering and rollback through red-green and a failed-candidate undo mutation. Co-authored-by: Copilot <[email protected]> Copilot-Session: 137c3de0-8937-4b62-aff3-13ce91c4cdcb --------- Co-authored-by: Copilot App <[email protected]> Co-authored-by: Copilot <[email protected]> Copilot-Session: 8ce30fb9-238f-4bb2-8f31-71e8d173c2ca Copilot-Session: 137c3de0-8937-4b62-aff3-13ce91c4cdcb
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <[email protected]>
* Remove always-on ErrorReportingOnStaticClasses flag Co-authored-by: Copilot <[email protected]> * Add release notes for ErrorReportingOnStaticClasses flag removal Co-authored-by: Copilot <[email protected]> Copilot-Session: 9f40324e-435c-473a-990c-f6d12e4d2884 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]> Copilot-Session: 9f40324e-435c-473a-990c-f6d12e4d2884
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This comment has been minimized.
This comment has been minimized.
Resolve the FS3923 diagnostic collision by assigning FS3924 to the NativePtr.stackalloc handler diagnostic and updating its tests and release note. Co-authored-by: Copilot <[email protected]>
|
🤖 LabelOps — conflict resolution. Merged current Validated the net11.0 Release component-test build and all 39
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "southcentralus0.in.applicationinsights.azure.com"See Network Configuration for more information.
|
Co-authored-by: Copilot <[email protected]>
Prevent immediate-consumption let elimination from moving frame-local allocations into exception handlers. Reuse the existing allocation detector, cover local functions and delegates in handler, filter, and finally contexts with optimization on and off, and update the release note. Co-authored-by: Copilot <[email protected]>
abonie
left a comment
There was a problem hiding this comment.
🤖🕵️ AI review — verify independently.
Preserve handler-local callable boundaries behind leading bindings and rank ready generic constraints by subtype ambiguity. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Resolve optimizer and NativeInterop test conflicts while preserving the remaining review fixes. Co-authored-by: Copilot App <[email protected]>
Adopt the review-feedback implementation already pushed to the PR branch. Co-authored-by: Copilot App <[email protected]>
abonie
left a comment
There was a problem hiding this comment.
🤖🕵️ AI review — verify independently.
Inspect two-target match branches before eliminating handler-local callable bindings, matching the computed-function application reduction shapes. Co-authored-by: Copilot App <[email protected]>
Preserve the validated NativePtr.stackalloc fixes and computed helper review fix while incorporating upstream metadata trimming behavior. Co-authored-by: Copilot <[email protected]>
Inspect extractable F# delegate bodies before eliminating handler-local callable bindings, and consolidate callable-shape coverage into the existing handler matrix. Co-authored-by: Copilot App <[email protected]>
Fixes #20295
NativePtr.stackallocinside thewithhandler, filter orfinallyblock of atry(directly or via an inlinable lambda) now reports error FS3916 instead of emitting alocallocthat the runtime rejects withInvalidProgramExceptionat method load.NativePtr.stackallocpassed as a chained base-constructor argument no longer produces an assembly that throwsInvalidProgramException; the base-constructor arguments are hoisted into locals before the uninitializedthisis pushed.