Repository navigation
Fix for issue #517 - #518
Merged
Merged
Conversation
Contributor
|
Looks great, thank you! |
1 task
dsyme
pushed a commit
that referenced
this pull request
Jul 29, 2026
…n type (#523) ## Problem The unit-return fix from #518 emits `I_ldnull` before `I_ret` whenever the method's return type is unit-like: ```fsharp let retUnit = retType = ILType.Void || retType.QualifiedName = (transType (convTypeToTgt typeof<unit>)).QualifiedName ... if retUnit then ilg.Emit(I_ldnull) ``` The check also matches `ILType.Void`, so a `ProvidedMethod` declared with `returnType = typeof<System.Void>` (which `transType` maps to `ILType.Void`) gets a stray null pushed onto the stack of a void-returning method. That is invalid IL — the stack must be empty at `ret` in a void method — and the JIT throws `InvalidProgramException` the first time the method is invoked: ``` System.InvalidProgramException : Common Language Runtime detected an invalid program. at VoidReturn.Provided.Container.Widget.DoNothing() ``` (The equivalent lambda path in `CodeGenerator.emitLambda` already gets this right: it emits `I_ldnull` only for the FSharp.Core `Unit` return type, not for void.) ## Fix Split the check: `retVoid` keeps the empty-stack behavior with no `ldnull`; only a genuine FSharp.Core `Unit` return pushes the boxed unit value `null`. ## Testing * New generative regression test declaring a `System.Void`-returning method and invoking it from the loaded assembly — fails with `InvalidProgramException` before the fix, passes after. * Full suite green: 161/161 (including the try-finally unit-return test added in #518). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
This fixes two minor codegen bugs for generative type providers, as described in issue #517 .
The 4 commits in this PR add a failing test for the first bug, fix the first bug to make the test pass, add a failing test for the second bug, and fix the second bug to make the test pass.