Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Fantomas.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ module Tainted
val GetHashCodeTainted: (Tainted<'T> -> int) when 'T: equality
"""

[<Test>]
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
"""

[<Test>]
let ``should keep access modifiers in signatures seperated`` () =
formatSourceString
Expand Down
5 changes: 3 additions & 2 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
14 changes: 12 additions & 2 deletions src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down