Skip to content

Commit 0d5f481

Browse files
committed
Add with keyword to SynPat.LongId for SynMemberDefn.Member.
1 parent 97e4223 commit 0d5f481

15 files changed

+327
-218
lines changed

src/fsharp/CheckDeclarations.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4708,7 +4708,7 @@ module TcDeclarations =
47084708
let attribs = attribs |> List.filter (fun a -> match a.Target with Some t when t.idText = "field" -> true | _ -> false)
47094709
let mLetPortion = synExpr.Range
47104710
let fldId = ident (CompilerGeneratedName id.idText, mLetPortion)
4711-
let headPat = SynPat.LongIdent (LongIdentWithDots([fldId], []), None, Some noInferredTypars, SynArgPats.Pats [], None, mLetPortion)
4711+
let headPat = SynPat.LongIdent (LongIdentWithDots([fldId], []), None, None, Some noInferredTypars, SynArgPats.Pats [], None, mLetPortion)
47124712
let retInfo = match tyOpt with None -> None | Some ty -> Some (SynReturnInfo((ty, SynInfo.unnamedRetVal), ty.Range))
47134713
let isMutable =
47144714
match propKind with
@@ -4736,7 +4736,7 @@ module TcDeclarations =
47364736
let attribs = attribs |> List.filter (fun a -> match a.Target with Some t when t.idText = "field" -> false | _ -> true)
47374737
let fldId = ident (CompilerGeneratedName id.idText, mMemberPortion)
47384738
let headPatIds = if isStatic then [id] else [ident ("__", mMemberPortion);id]
4739-
let headPat = SynPat.LongIdent (LongIdentWithDots(headPatIds, []), None, Some noInferredTypars, SynArgPats.Pats [], None, mMemberPortion)
4739+
let headPat = SynPat.LongIdent (LongIdentWithDots(headPatIds, []), None, None, Some noInferredTypars, SynArgPats.Pats [], None, mMemberPortion)
47404740

47414741
match propKind, mGetSetOpt with
47424742
| SynMemberKind.PropertySet, Some m -> errorR(Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSetNotJustSet(), m))
@@ -4761,7 +4761,7 @@ module TcDeclarations =
47614761
| SynMemberKind.PropertyGetSet ->
47624762
let setter =
47634763
let vId = ident("v", mMemberPortion)
4764-
let headPat = SynPat.LongIdent (LongIdentWithDots(headPatIds, []), None, Some noInferredTypars, SynArgPats.Pats [mkSynPatVar None vId], None, mMemberPortion)
4764+
let headPat = SynPat.LongIdent (LongIdentWithDots(headPatIds, []), None, None, Some noInferredTypars, SynArgPats.Pats [mkSynPatVar None vId], None, mMemberPortion)
47654765
let rhsExpr = mkSynAssign (SynExpr.Ident fldId) (SynExpr.Ident vId)
47664766
//let retInfo = match tyOpt with None -> None | Some ty -> Some (SynReturnInfo((ty, SynInfo.unnamedRetVal), ty.Range))
47674767
let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, None, None, rhsExpr, rhsExpr.Range, [], [], Some (memberFlags SynMemberKind.PropertySet))

src/fsharp/CheckExpressions.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,7 +2428,7 @@ module BindingNormalization =
24282428
// of available items, to the point that you can't even define a function with the same name as an existing union case.
24292429
match pat with
24302430
| SynPat.FromParseError(p, _) -> normPattern p
2431-
| SynPat.LongIdent (LongIdentWithDots(longId, _), toolId, tyargs, SynArgPats.Pats args, vis, m) ->
2431+
| SynPat.LongIdent (longDotId=LongIdentWithDots(longId, _); extraId=toolId; typarDecls=tyargs; argPats=SynArgPats.Pats args; accessibility=vis; range=m) ->
24322432
let typars = match tyargs with None -> inferredTyparDecls | Some typars -> typars
24332433
match memberFlagsOpt with
24342434
| None ->
@@ -4962,7 +4962,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
49624962
let pats', acc = TcPatterns warnOnUpper cenv env vFlags (tpenv, names, takenNames) (List.map (fun _ -> ty) pats) pats
49634963
(fun values -> TPat_conjs(List.map (fun f -> f values) pats', m)), acc
49644964

4965-
| SynPat.LongIdent (LongIdentWithDots(longId, _), _, tyargs, args, vis, m) ->
4965+
| SynPat.LongIdent (longDotId=LongIdentWithDots(longId, _); typarDecls=tyargs; argPats=args; accessibility=vis; range=m) ->
49664966
if Option.isSome tyargs then errorR(Error(FSComp.SR.tcInvalidTypeArgumentUsage(), m))
49674967
let warnOnUpperForId =
49684968
match args with
@@ -4994,7 +4994,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
49944994
| SynPat.Const (c, m) -> SynExpr.Const (c, m)
49954995
| SynPat.Named (id, _, None, _) -> SynExpr.Ident id
49964996
| SynPat.Typed (p, cty, m) -> SynExpr.Typed (convSynPatToSynExpr p, cty, m)
4997-
| SynPat.LongIdent (LongIdentWithDots(longId, dotms) as lidwd, _, _tyargs, args, None, m) ->
4997+
| SynPat.LongIdent (longDotId=LongIdentWithDots(longId, dotms) as lidwd; argPats=args; accessibility=None; range=m) ->
49984998
let args = match args with SynArgPats.Pats args -> args | _ -> failwith "impossible: active patterns can be used only with SynConstructorArgs.Pats"
49994999
let e =
50005000
if dotms.Length = longId.Length then
@@ -9620,7 +9620,7 @@ and CheckRecursiveBindingIds binds =
96209620
match b with
96219621
| SynPat.Named(id, _, _, _)
96229622
| SynPat.As(_, SynPat.Named(id, _, _, _), _)
9623-
| SynPat.LongIdent(LongIdentWithDots([id], _), _, _, _, _, _) -> id.idText
9623+
| SynPat.LongIdent(longDotId=LongIdentWithDots([id], _)) -> id.idText
96249624
| _ -> ""
96259625
if nm <> "" && not (hashOfBinds.Add nm) then
96269626
error(Duplicate("value", nm, m))

src/fsharp/SyntaxTree.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ type SynPat =
10901090

10911091
| LongIdent of
10921092
longDotId: LongIdentWithDots *
1093+
propertyKeyword: PropertyKeyword option *
10931094
extraId: Ident option * // holds additional ident for tooling
10941095
typarDecls: SynValTyparDecls option * // usually None: temporary used to parse "f<'a> x = x"
10951096
argPats: SynArgPats *
@@ -1168,6 +1169,11 @@ type SynPat =
11681169
| SynPat.Paren (range=m)
11691170
| SynPat.FromParseError (range=m) -> m
11701171

1172+
[<NoEquality; NoComparison; RequireQualifiedAccess>]
1173+
type PropertyKeyword =
1174+
| With of Range
1175+
| And of Range
1176+
11711177
[<NoEquality; NoComparison;>]
11721178
type SynInterfaceImpl =
11731179
| SynInterfaceImpl of

src/fsharp/SyntaxTree.fsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,7 @@ type SynPat =
12301230
/// A long identifier pattern possibly with argument patterns
12311231
| LongIdent of
12321232
longDotId: LongIdentWithDots *
1233+
propertyKeyword: PropertyKeyword option *
12331234
extraId: Ident option * // holds additional ident for tooling
12341235
typarDecls: SynValTyparDecls option * // usually None: temporary used to parse "f<'a> x = x"
12351236
argPats: SynArgPats *
@@ -1299,6 +1300,11 @@ type SynPat =
12991300
/// Gets the syntax range of this construct
13001301
member Range: range
13011302

1303+
[<NoEquality; NoComparison; RequireQualifiedAccess>]
1304+
type PropertyKeyword =
1305+
| With of Range
1306+
| And of Range
1307+
13021308
/// Represents a set of bindings that implement an interface
13031309
[<NoEquality; NoComparison;>]
13041310
type SynInterfaceImpl =

src/fsharp/SyntaxTreeOps.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ let mkSynPatVar vis (id: Ident) = SynPat.Named (id, false, vis, id.idRange)
9797

9898
let mkSynThisPatVar (id: Ident) = SynPat.Named (id, true, None, id.idRange)
9999

100-
let mkSynPatMaybeVar lidwd vis m = SynPat.LongIdent (lidwd, None, None, SynArgPats.Pats [], vis, m)
100+
let mkSynPatMaybeVar lidwd vis m = SynPat.LongIdent (lidwd, None, None, None, SynArgPats.Pats [], vis, m)
101101

102102
/// Extract the argument for patterns corresponding to the declaration of 'new ... = ...'
103103
let (|SynPatForConstructorDecl|_|) x =
104104
match x with
105-
| SynPat.LongIdent (LongIdentWithDots([_], _), _, _, SynArgPats.Pats [arg], _, _) -> Some arg
105+
| SynPat.LongIdent (longDotId=LongIdentWithDots([_], _); argPats=SynArgPats.Pats [arg]) -> Some arg
106106
| _ -> None
107107

108108
/// Recognize the '()' in 'new()'
@@ -156,7 +156,7 @@ let rec SimplePatOfPat (synArgNameGenerator: SynArgNameGenerator) p =
156156
let m = p.Range
157157
let isCompGen, altNameRefCell, id, item =
158158
match p with
159-
| SynPat.LongIdent(LongIdentWithDots([id], _), _, None, SynArgPats.Pats [], None, _) ->
159+
| SynPat.LongIdent(longDotId=LongIdentWithDots([id], _); typarDecls=None; argPats=SynArgPats.Pats []; accessibility=None) ->
160160
// The pattern is 'V' or some other capitalized identifier.
161161
// It may be a real variable, in which case we want to maintain its name.
162162
// But it may also be a nullary union case or some other identifier.
@@ -530,12 +530,12 @@ module SynInfo =
530530

531531
let infosForExplicitArgs =
532532
match pat with
533-
| Some(SynPat.LongIdent(_, _, _, SynArgPats.Pats curriedArgs, _, _)) -> List.map InferSynArgInfoFromPat curriedArgs
533+
| Some(SynPat.LongIdent(argPats=SynArgPats.Pats curriedArgs)) -> List.map InferSynArgInfoFromPat curriedArgs
534534
| _ -> []
535535

536536
let explicitArgsAreSimple =
537537
match pat with
538-
| Some(SynPat.LongIdent(_, _, _, SynArgPats.Pats curriedArgs, _, _)) -> List.forall isSimplePattern curriedArgs
538+
| Some(SynPat.LongIdent(argPats=SynArgPats.Pats curriedArgs)) -> List.forall isSimplePattern curriedArgs
539539
| _ -> true
540540

541541
let retInfo = InferSynReturnData retInfo

0 commit comments

Comments
 (0)