diff --git a/src/Fantomas.Tests/SignatureTests.fs b/src/Fantomas.Tests/SignatureTests.fs index b9eed23bc2..5c683b1eab 100644 --- a/src/Fantomas.Tests/SignatureTests.fs +++ b/src/Fantomas.Tests/SignatureTests.fs @@ -171,6 +171,24 @@ module Tainted val GetHashCodeTainted: (Tainted<'T> -> int) when 'T: equality """ +[] +let ``should keep mutable in type signature, 1954`` () = + formatSourceString + true + """ +module Tainted +val mutable showParserStackOnParseError: bool +""" + config + |> prepend newline + |> should + equal + """ +module Tainted + +val mutable showParserStackOnParseError: bool +""" + [] let ``should keep access modifiers in signatures seperated`` () = formatSourceString diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index b7870f753f..a11012a516 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -867,7 +867,7 @@ and genMemberFlagsForMemberBinding astContext (mf: MemberFlags) (rangeOfBindingA |> Option.defaultValue (!- "override ") <| ctx -and genVal astContext (Val (ats, px, ao, s, identRange, t, vi, isInline, _, eo) as node) = +and genVal astContext (Val (ats, px, ao, s, identRange, t, vi, isInline, isMutable, _, eo) as node) = let range, synValTyparDecls = match node with | ValSpfn (_, _, synValTyparDecls, _, _, _, _, _, _, _, range) -> range, synValTyparDecls @@ -883,6 +883,7 @@ and genVal astContext (Val (ats, px, ao, s, identRange, t, vi, isInline, _, eo) +> genAttributes astContext ats +> (!- "val " +> onlyIf isInline (!- "inline ") + +> onlyIf isMutable (!- "mutable ") +> opt sepSpace ao genAccess -- s +> genericParams @@ -4045,7 +4046,7 @@ and genMemberSig astContext node = | SynMemberSig.NestedType (_, r) -> r, SynMemberSig_NestedType match node with - | MSMember (Val (ats, px, ao, s, _, t, vi, isInline, ValTyparDecls (tds, _, tcs), eo), mf) -> + | MSMember (Val (ats, px, ao, s, _, t, vi, isInline, _, ValTyparDecls (tds, _, tcs), eo), mf) -> let (FunType namedArgs) = (t, vi) let isFunctionProperty = diff --git a/src/Fantomas/SourceParser.fs b/src/Fantomas/SourceParser.fs index 3a29e4af27..6fd51bee08 100644 --- a/src/Fantomas/SourceParser.fs +++ b/src/Fantomas/SourceParser.fs @@ -1510,9 +1510,19 @@ let (|MSMember|MSInterface|MSInherit|MSValField|MSNestedType|) = | SynMemberSig.NestedType (tds, _) -> MSNestedType tds let (|Val|) - (ValSpfn (ats, (IdentOrKeyword (OpNameFullInPattern (s, _)) as ident), tds, t, vi, isInline, _, px, ao, eo, _)) + (ValSpfn (ats, + (IdentOrKeyword (OpNameFullInPattern (s, _)) as ident), + tds, + t, + vi, + isInline, + isMutable, + px, + ao, + eo, + _)) = - (ats, px, ao, s, ident.idRange, t, vi, isInline, tds, eo) + (ats, px, ao, s, ident.idRange, t, vi, isInline, isMutable, tds, eo) // Misc