Skip to content

Commit c01bc47

Browse files
authored
Use a more accurate range for CE Combine methods (#18394)
1 parent af2ebfa commit c01bc47

File tree

4 files changed

+543
-3
lines changed

4 files changed

+543
-3
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.300.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* Symbols: Add FSharpAssembly.IsFSharp ([PR #18290](https://github.com/dotnet/fsharp/pull/18290))
3030
* Type parameter constraint `null` in generic code will now automatically imply `not struct` ([Issue #18320](https://github.com/dotnet/fsharp/issues/18320), [PR #18323](https://github.com/dotnet/fsharp/pull/18323))
3131
* Add a switch to determine whether to generate a default implementation body for overridden method when completing. [PR #18341](https://github.com/dotnet/fsharp/pull/18341)
32+
* Use a more accurate range for CE Combine methods. [PR #18394](https://github.com/dotnet/fsharp/pull/18394)
3233

3334

3435
### Changed

src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,12 @@ let rec TryTranslateComputationExpression
16121612
// "cexpr; cexpr" is treated as builder.Combine(cexpr1, cexpr1)
16131613
let m1 = rangeForCombine innerComp1
16141614

1615+
let combineDelayRange =
1616+
match innerComp2 with
1617+
| SynExpr.YieldOrReturn(trivia = yieldOrReturn) -> yieldOrReturn.YieldOrReturnKeyword
1618+
| SynExpr.YieldOrReturnFrom(trivia = yieldOrReturnFrom) -> yieldOrReturnFrom.YieldOrReturnFromKeyword
1619+
| expr -> expr.Range
1620+
16151621
if
16161622
isNil (
16171623
TryFindIntrinsicOrExtensionMethInfo
@@ -1624,7 +1630,8 @@ let rec TryTranslateComputationExpression
16241630
ceenv.builderTy
16251631
)
16261632
then
1627-
error (Error(FSComp.SR.tcRequireBuilderMethod ("Combine"), m))
1633+
1634+
error (Error(FSComp.SR.tcRequireBuilderMethod "Combine", combineDelayRange))
16281635

16291636
if
16301637
isNil (
@@ -1638,7 +1645,7 @@ let rec TryTranslateComputationExpression
16381645
ceenv.builderTy
16391646
)
16401647
then
1641-
error (Error(FSComp.SR.tcRequireBuilderMethod ("Delay"), m))
1648+
error (Error(FSComp.SR.tcRequireBuilderMethod "Delay", combineDelayRange))
16421649

16431650
let combineCall =
16441651
mkSynCall

0 commit comments

Comments
 (0)