fix(fsharp): propagate DerivedVariable IsReferenced to same-named Arguments - #563
Merged
Conversation
…uments
WriteFSharpMethod prefixes unreferenced method arguments with `_` to
satisfy
the F# compiler's unused-variable warnings. The check used
arg.IsReferenced,
but a method argument and a DerivedVariable that aliases the same name
are
distinct Variable instances — so marking one referenced had no effect on
the
other.
Concrete case: Wolverine's HandlerChain adds ContextVariable("context",
IMessageContext) to DerivedVariables so middleware can resolve
IMessageContext.
When a middleware frame resolves that alias and marks it referenced, the
actual
HandleAsync argument (`context: MessageContext`) stayed IsReferenced =
false.
WriteFSharpMethod then emitted `_context` in the signature while the
generated
body still used `context`, producing FS0039 ("value or constructor
'context' is
not defined") on every handler that had IMessageContext-consuming
middleware.
Fix: before building the argument list in WriteFSharpMethod, walk
Arguments and
set IsReferenced = true on any whose Usage matches a referenced
DerivedVariable.
Setting it on the Variable object itself (inside the JasperFx assembly,
so
`internal set` is reachable) keeps all downstream codegen — including
frames
that read arg.IsReferenced directly — consistent with the updated state.
This was referenced Jul 30, 2026
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.
WriteFSharpMethod prefixes unreferenced method arguments with
_tosatisfy
the F# compiler's unused-variable warnings. The check used
arg.IsReferenced,
but a method argument and a DerivedVariable that aliases the same name
are
distinct Variable instances — so marking one referenced had no effect on
the
other.
Concrete case: Wolverine's HandlerChain adds ContextVariable("context",
IMessageContext) to DerivedVariables so middleware can resolve
IMessageContext.
When a middleware frame resolves that alias and marks it referenced, the
actual
HandleAsync argument (
context: MessageContext) stayed IsReferenced =false.
WriteFSharpMethod then emitted
_contextin the signature while thegenerated
body still used
context, producing FS0039 ("value or constructor'context' is
not defined") on every handler that had IMessageContext-consuming
middleware.
Fix: before building the argument list in WriteFSharpMethod, walk
Arguments and
set IsReferenced = true on any whose Usage matches a referenced
DerivedVariable.
Setting it on the Variable object itself (inside the JasperFx assembly,
so
internal setis reachable) keeps all downstream codegen — includingframes
that read arg.IsReferenced directly — consistent with the updated state.