-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Labels
Description
Issue created from fantomas-online
Code
type MyCSharpClass() =
member val Prop = 0.0m with get, set
member val Prop2 = 0.0m with get, set
type FSharpType = {
SomeValue: string option
}
let v = { SomeValue = Some "str" }
let instance =
MyClass(
Prop =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m
,
Prop2 =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m
)
Result
type MyCSharpClass() =
member val Prop = 0.0m with get, set
member val Prop2 = 0.0m with get, set
type FSharpType = { SomeValue: string option }
let v = { SomeValue = Some "str" }
let instance =
MyClass(
Prop =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m,
Prop2 =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m
)
Problem description
It seems that when we have multiple match statements passed to named parameters for a class it places the ,
in the wrong place. That results in a dotnet fantomas
error.
Known workarounds are:
- surround the match statement with
()
,
let instance =
MyClass(
(Prop =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m)
,
(Prop2 =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m)
)
- extract the match statement to an explicit variable.
let instance =
let v1 =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m
let v2 =
match value.SomeValue with
| Some _ -> 0.0m
| None -> 0.0m
MyClass(
Prop = v1,
Prop2 = v2
)
Extra information
- The formatted result breaks my code.
- The formatted result gives compiler warnings.
- I or my company would be willing to help fix this.
Options
Fantomas main branch at 2023-04-20T16:04:28Z - 4ed1e9d
Default Fantomas configuration
- Fantomas v6,
- .NET6