F# codegen: emit a named this self identifier (#393)#394
Merged
Conversation
Generated F# members were emitted as `member _.X(...)`, discarding the self identifier. C# generated handlers routinely call inherited instance members unqualified (implicit `this`) — e.g. a Wolverine.Http HttpHandler subclass calls the base `ReadJsonAsync`/`WriteJsonAsync`, and a MessageHandler subclass calls `RecordCauseAndEffect`. F# has no implicit `this`, so `member _.` left those calls unresolvable and blocked the Wolverine F# audit's HTTP JSON path (JasperFx/wolverine#2969 Phase C). - GeneratedMethod.WriteFSharpMethod now emits `member this.` / `override this.`. F# does not warn on an unused member self identifier (unlike an unused `let`), so the original unused-`this` concern doesn't apply. - MethodCall F# emit renders `IsLocal` calls as `this.method(...)` (was the empty prefix), matching the implicit-`this` semantics of the C# path. - Fixture: a new GeneratedCalculator overrides a base abstract method and calls the inherited instance `Bump` via a local MethodCall, so the compile gate proves `override this.Compute` + `this.Bump(seed)` emits valid, compiling F#. - Updated the four FSharpGenerationTests assertions from `member _.` to `member this.`. Closes #393. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
this self identifier (#393)
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.
Closes #393.
Problem
Generated F# members were emitted as
member _.X(...), discarding the self identifier. C# generated handlers routinely call inherited instance members unqualified (relying on implicitthis) — e.g. aWolverine.Http.HttpHandlersubclass calls the base instanceReadJsonAsync/WriteJsonAsync, and aMessageHandlersubclass callsRecordCauseAndEffect. F# has no implicitthis, somember _.left those calls unresolvable, blocking the Wolverine F# audit's HTTP JSON path (JasperFx/wolverine#2969, Phase C).Fix
GeneratedMethod.WriteFSharpMethodnow emitsmember this./override this.. F# does not warn on an unused member self identifier (unlike an unusedletbinding), so the original unused-thisconcern doesn't apply, and the F# fixtures don't run warnings-as-errors.MethodCallF# emit rendersIsLocalcalls asthis.method(...)(was the empty prefix), matching the implicit-thissemantics of the C# path.Test
A new
GeneratedCalculatorfixture type overrides a base abstract method and calls the inherited instanceBumpvia a localMethodCall, so the compile gate proves the emitted F# compiles:The four
FSharpGenerationTestsself-identifier assertions were updatedmember _.→member this..Verification
CodegenTestsF# generation/unit tests: 30/30 pass (net9.0 + net10.0).CodegenTests.FSharpcompile gate: the regeneratedGenerated.fs(nowthis.throughout, incl. the new inherited-call case) compiles viadotnet buildon both TFMs.🤖 Generated with Claude Code