Fix lost source range for empty-bodied computation expressions in pipelines (#19550)#19849
Open
T-Gro wants to merge 2 commits into
Open
Fix lost source range for empty-bodied computation expressions in pipelines (#19550)#19849T-Gro wants to merge 2 commits into
T-Gro wants to merge 2 commits into
Conversation
…elines (#19550) - Pass mExprAndArg (full App range) instead of mLeftExpr as mWhole to TcComputationExpression so that the synthesized Zero() call has a meaningful range when the CE body is empty. - Fall back to ceenv.mWhole inside the SynExpr.ImplicitZero translation when the incoming range is range0, defensively preventing zero-ranged synthesized calls from reaching codegen / diagnostics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds the CE_PipelineRange19550 test file (registered in the ComponentTests fsproj) and a release-notes bullet in 11.0.100.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
❗ Release notes required
Warning No PR link found in some release notes, please consider adding it.
|
auduchinok
reviewed
May 29, 2026
| | _ -> error (Error(FSComp.SR.tcRequireBuilderMethod "Zero", m)) | ||
|
|
||
| Some(translatedCtxt (mkSynCall "Zero" m [] ceenv.builderValName)) | ||
| let mCall = if equals m range0 then ceenv.mWhole else m |
Member
There was a problem hiding this comment.
Can we locate the place where the wrong range was set in the first place?
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.
Summary
Fixes #19550
When a computation expression with an empty body (e.g.
foo {}) is used in a pipeline, the synthesizedZero()call was givenrange0(i.e.unknown(1,1)) instead of the actual source location. This caused type mismatch errors to report nonsensical locations and LSP diagnostics to be lost.Changes
mExprAndArg(the full App range) instead ofmLeftExpras themWholeparameter toTcComputationExpression, so the synthesizedZero()call receives a meaningful range when the CE body is empty.SynExpr.ImplicitZerotranslation, fall back toceenv.mWholewhen the incoming range isrange0, defensively preventing zero-ranged synthesized calls from reaching codegen/diagnostics.Tests
Added
tests/FSharp.Compiler.ComponentTests/Language/CE_PipelineRange19550.fswith comprehensive tests covering:Release Notes
Added entry in
docs/release-notes/.FSharp.Compiler.Service/11.0.100.md.