Skip to content

Commit 854d9b3

Browse files
authored
Merge pull request #3094 from dawedawe/fix_2866
Guard against a newline induced precedence change
2 parents 7676a03 + 268a36b commit 854d9b3

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Changelog
22

3-
## [Unreleased]
3+
## 6.3.8 - 2024-06-06
44

55
### Fixed
6-
* Fix loss of tuple type annotation without parens. [#2942](https://github.com/fsprojects/fantomas/issues/2942)
6+
* Fix precedence change of `||>` due to inserted newline. [#2866](https://github.com/fsprojects/fantomas/issues/2866)
77

88
## 6.3.7 - 2024-06-01
99

src/Fantomas.Core.Tests/PatternMatchingTests.fs

+23
Original file line numberDiff line numberDiff line change
@@ -2286,3 +2286,26 @@ match synExpr with
22862286
) -> Some ident.idRange
22872287
| _ -> defaultTraverse synExpr
22882288
"""
2289+
2290+
[<Test>]
2291+
let ``insertion of a newline changes precedence of the ||> operator, 2866`` () =
2292+
formatSourceString
2293+
"""
2294+
let value =
2295+
match "string" with
2296+
| "value" -> "1", "2"
2297+
| _ -> "111111111111111111111111111111111111111111111111111111111111111111111", "22222222222222222222222222222222222"
2298+
||> createTuple
2299+
"""
2300+
config
2301+
|> prepend newline
2302+
|> should
2303+
equal
2304+
"""
2305+
let value =
2306+
(match "string" with
2307+
| "value" -> "1", "2"
2308+
| _ ->
2309+
"111111111111111111111111111111111111111111111111111111111111111111111", "22222222222222222222222222222222222")
2310+
||> createTuple
2311+
"""

src/Fantomas.Core/CodePrinter.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,7 @@ let genMultilineInfixExpr (node: ExprInfixAppNode) =
21632163
match node.LeftHandSide with
21642164
| IsIfThenElse _ when (ctx.Config.IndentSize - 1 <= node.Operator.Text.Length) ->
21652165
autoParenthesisIfExpressionExceedsPageWidth (genExpr node.LeftHandSide) ctx
2166-
| Expr.Match _ when (ctx.Config.IndentSize <= node.Operator.Text.Length) ->
2166+
| Expr.Match _ when (ctx.Config.IndentSize - 1 <= node.Operator.Text.Length) ->
21672167
let ctxAfterMatch = genExpr node.LeftHandSide ctx
21682168

21692169
let lastClauseIsSingleLine =

0 commit comments

Comments
 (0)