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
2 changes: 1 addition & 1 deletion src/fsharp/CheckComputationExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ let TcComputationExpression (cenv: cenv) env (overallTy: OverallTy) tpenv (mWhol

// 'use! pat = e1 in e2' --> build.Bind(e1, (function _argN -> match _argN with pat -> build.Using(x, (fun _argN -> match _argN with pat -> e2))))
| SynExpr.LetOrUseBang (bindDebugPoint=spBind; isUse=true; isFromSource=isFromSource; pat=SynPat.Named (ident=SynIdent(id,_); isThisVal=false) as pat; rhs=rhsExpr; andBangs=[]; body=innerComp)
| SynExpr.LetOrUseBang (bindDebugPoint=spBind; isUse=true; isFromSource=isFromSource; pat=SynPat.LongIdent (longDotId=LongIdentWithDots([id], _)) as pat; rhs=rhsExpr; andBangs=[]; body=innerComp) ->
| SynExpr.LetOrUseBang (bindDebugPoint=spBind; isUse=true; isFromSource=isFromSource; pat=SynPat.LongIdent (longDotId=SynLongIdent([id], _, _)) as pat; rhs=rhsExpr; andBangs=[]; body=innerComp) ->

let mBind = match spBind with DebugPointAtBinding.Yes m -> m | _ -> rhsExpr.Range
if isQuery then error(Error(FSComp.SR.tcBindMayNotBeUsedInQueries(), mBind))
Expand Down
10 changes: 5 additions & 5 deletions src/fsharp/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3182,7 +3182,7 @@ module EstablishTypeDefinitionCores =

let private (|TyconCoreAbbrevThatIsReallyAUnion|_|) (hasMeasureAttr, envinner: TcEnv, id: Ident) synTyconRepr =
match synTyconRepr with
| SynTypeDefnSimpleRepr.TypeAbbrev(_, StripParenTypes (SynType.LongIdent(LongIdentWithDots([unionCaseName], _))), m)
| SynTypeDefnSimpleRepr.TypeAbbrev(_, StripParenTypes (SynType.LongIdent(SynLongIdent([unionCaseName], _, _))), m)
when
(not hasMeasureAttr &&
(isNil (LookupTypeNameInEnvNoArity OpenQualified unionCaseName.idText envinner.NameEnv) ||
Expand Down Expand Up @@ -3531,9 +3531,9 @@ module EstablishTypeDefinitionCores =
/// Get the items on the r.h.s. of a 'type X = ABC<...>' definition
let private TcTyconDefnCore_GetGenerateDeclaration_Rhs (StripParenTypes rhsType) =
match rhsType with
| SynType.App (StripParenTypes (SynType.LongIdent(LongIdentWithDots(tc, _))), _, args, _commas, _, _postfix, m) -> Some(tc, args, m)
| SynType.LongIdent (LongIdentWithDots(tc, _) as lidwd) -> Some(tc, [], lidwd.Range)
| SynType.LongIdentApp (StripParenTypes (SynType.LongIdent (LongIdentWithDots(tc, _))), LongIdentWithDots(longId, _), _, args, _commas, _, m) -> Some(tc@longId, args, m)
| SynType.App (StripParenTypes (SynType.LongIdent(SynLongIdent(tc, _, _))), _, args, _commas, _, _postfix, m) -> Some(tc, args, m)
| SynType.LongIdent (SynLongIdent(tc, _, _) as lidwd) -> Some(tc, [], lidwd.Range)
| SynType.LongIdentApp (StripParenTypes (SynType.LongIdent (SynLongIdent(tc, _, _))), SynLongIdent(longId, _, _), _, args, _commas, _, m) -> Some(tc@longId, args, m)
| _ -> None

/// Check whether 'type X = ABC<...>' is a generative provided type definition
Expand Down Expand Up @@ -5071,7 +5071,7 @@ module TcDeclarations =
memberFlags.MemberKind=SynMemberKind.Constructor &&
// REVIEW: This is a syntactic approximation
(match valSpfn.SynType, valSpfn.SynInfo.CurriedArgInfos with
| StripParenTypes (SynType.Fun (StripParenTypes (SynType.LongIdent (LongIdentWithDots([id], _))), _, _)), [[_]] when id.idText = "unit" -> true
| StripParenTypes (SynType.Fun (StripParenTypes (SynType.LongIdent (SynLongIdent([id], _, _))), _, _)), [[_]] when id.idText = "unit" -> true
| _ -> false)
| _ -> false)

Expand Down
34 changes: 17 additions & 17 deletions src/fsharp/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,7 @@ module BindingNormalization =
// of available items, to the point that you can't even define a function with the same name as an existing union case.
match pat with
| SynPat.FromParseError(p, _) -> normPattern p
| SynPat.LongIdent (LongIdentWithDots(longId, _), _, toolId, tyargs, SynArgPats.Pats args, vis, m) ->
| SynPat.LongIdent (SynLongIdent(longId, _, _), _, toolId, tyargs, SynArgPats.Pats args, vis, m) ->
let typars = match tyargs with None -> inferredTyparDecls | Some typars -> typars
match memberFlagsOpt with
| None ->
Expand Down Expand Up @@ -3152,12 +3152,12 @@ let (|SimpleEqualsExpr|_|) expr =
/// Detect a named argument at a callsite
let TryGetNamedArg expr =
match expr with
| SimpleEqualsExpr(LongOrSingleIdent(isOpt, LongIdentWithDots([a], _), None, _), b) -> Some(isOpt, a, b)
| SimpleEqualsExpr(LongOrSingleIdent(isOpt, SynLongIdent([a], _, _), None, _), b) -> Some(isOpt, a, b)
| _ -> None

let inline IsNamedArg expr =
match expr with
| SimpleEqualsExpr(LongOrSingleIdent(_, LongIdentWithDots([_], _), None, _), _) -> true
| SimpleEqualsExpr(LongOrSingleIdent(_, SynLongIdent([_], _, _), None, _), _) -> true
| _ -> false

/// Get the method arguments at a callsite, taking into account named and optional arguments
Expand Down Expand Up @@ -4316,11 +4316,11 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: UnscopedTyparEnv
let g = cenv.g

match ty with
| SynType.LongIdent(LongIdentWithDots([], _)) ->
| SynType.LongIdent(SynLongIdent([], _, _)) ->
// special case when type name is absent - i.e. empty inherit part in type declaration
g.obj_ty, tpenv

| SynType.LongIdent(LongIdentWithDots(tc, _) as lidwd) ->
| SynType.LongIdent(SynLongIdent(tc, _, _) as lidwd) ->
let m = lidwd.Range
let ad = env.eAccessRights
let tinstEnclosing, tcref = ForceRaise(ResolveTypeLongIdent cenv.tcSink cenv.nameResolver occ OpenQualified env.NameEnv ad tc TypeNameResolutionStaticArgsInfo.DefiniteEmpty PermitDirectReferenceToGeneratedType.No)
Expand All @@ -4336,7 +4336,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: UnscopedTyparEnv
| _, TyparKind.Type ->
TcTypeApp cenv newOk checkCxs occ env tpenv m tcref tinstEnclosing []

| SynType.App (StripParenTypes (SynType.LongIdent(LongIdentWithDots(tc, _))), _, args, _commas, _, postfix, m) ->
| SynType.App (StripParenTypes (SynType.LongIdent(SynLongIdent(tc, _, _))), _, args, _commas, _, postfix, m) ->
let ad = env.eAccessRights

let tinstEnclosing, tcref =
Expand Down Expand Up @@ -4367,7 +4367,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: UnscopedTyparEnv
errorR(Error(FSComp.SR.tcUnitsOfMeasureInvalidInTypeConstructor(), m))
NewErrorType (), tpenv

| SynType.LongIdentApp (ltyp, LongIdentWithDots(longId, _), _, args, _commas, _, m) ->
| SynType.LongIdentApp (ltyp, SynLongIdent(longId, _, _), _, args, _commas, _, m) ->
let ad = env.eAccessRights
let ltyp, tpenv = TcType cenv newOk checkCxs occ env tpenv ltyp
match ltyp with
Expand Down Expand Up @@ -4631,7 +4631,7 @@ and TcStaticConstantParameter cenv (env: TcEnv) tpenv kind (StripParenTypes v) i
and CrackStaticConstantArgs cenv env tpenv (staticParameters: Tainted<ProvidedParameterInfo>[], args: SynType list, container, containerName, m) =
let args =
args |> List.map (function
| StripParenTypes (SynType.StaticConstantNamed(StripParenTypes (SynType.LongIdent(LongIdentWithDots([id], _))), v, _)) -> Some id, v
| StripParenTypes (SynType.StaticConstantNamed(StripParenTypes (SynType.LongIdent(SynLongIdent([id], _, _))), v, _)) -> Some id, v
| v -> None, v)

let unnamedArgs = args |> Seq.takeWhile (fst >> Option.isNone) |> Seq.toArray |> Array.map snd
Expand Down Expand Up @@ -5197,7 +5197,7 @@ and IsNameOf (cenv: cenv) (env: TcEnv) ad m (id: Ident) =

/// Check a long identifier in a pattern
and TcPatLongIdent warnOnUpper cenv env ad topValInfo vFlags (tpenv, names, takenNames) ty (longDotId, tyargs, args, vis, m) =
let (LongIdentWithDots(longId, _)) = longDotId
let (SynLongIdent(longId, _, _)) = longDotId

if tyargs.IsSome then errorR(Error(FSComp.SR.tcInvalidTypeArgumentUsage(), m))

Expand Down Expand Up @@ -5688,7 +5688,7 @@ and TcExprThen cenv (overallTy: OverallTy) env tpenv isArg synExpr delayed =
// e1.id1
// e1.id1.id2
// etc.
| SynExpr.DotGet (e1, _, LongIdentWithDots(longId, _), _) ->
| SynExpr.DotGet (e1, _, SynLongIdent(longId, _, _), _) ->
TcNonControlFlowExpr env <| fun env ->
TcExprThen cenv overallTy env tpenv false e1 ((DelayedDotLookup (longId, synExpr.RangeWithoutAnyExtraDot)) :: delayed)

Expand Down Expand Up @@ -6407,7 +6407,7 @@ and TcExprStaticOptimization cenv overallTy env tpenv (constraints, e2, e3, m) =

/// e1.longId <- e2
and TcExprDotSet cenv overallTy env tpenv (e1, lidwd, e2, mStmt) =
let (LongIdentWithDots(longId, _)) = lidwd
let (SynLongIdent(longId, _, _)) = lidwd

if lidwd.ThereIsAnExtraDotAtTheEnd then
// just drop rhs on the floor
Expand All @@ -6419,7 +6419,7 @@ and TcExprDotSet cenv overallTy env tpenv (e1, lidwd, e2, mStmt) =

/// e1.longId(e2) <- e3, very rarely used named property setters
and TcExprDotNamedIndexedPropertySet cenv overallTy env tpenv (e1, lidwd, e2, e3, mStmt) =
let (LongIdentWithDots(longId, _)) = lidwd
let (SynLongIdent(longId, _, _)) = lidwd
if lidwd.ThereIsAnExtraDotAtTheEnd then
// just drop rhs on the floor
let mExprAndDotLookup = unionRanges e1.Range (rangeOfLid longId)
Expand Down Expand Up @@ -8253,7 +8253,7 @@ and TcNameOfExpr cenv env tpenv (synArg: SynExpr) =
let m = cleanSynArg.Range
let rec check overallTyOpt resultOpt expr (delayed: DelayedItem list) =
match expr with
| LongOrSingleIdent (false, LongIdentWithDots(longId, _), _, _) ->
| LongOrSingleIdent (false, SynLongIdent(longId, _, _), _, _) ->

let ad = env.eAccessRights
let result = defaultArg resultOpt (List.last longId)
Expand Down Expand Up @@ -8333,7 +8333,7 @@ and TcNameOfExpr cenv env tpenv (synArg: SynExpr) =
check overallTyOpt resultOpt hd (DelayedTypeApp(types, m, m) :: delayed)

// expr.ID allowed
| SynExpr.DotGet (hd, _, LongIdentWithDots(longId, _), _) ->
| SynExpr.DotGet (hd, _, SynLongIdent(longId, _, _), _) ->
let result = defaultArg resultOpt (List.last longId)
check overallTyOpt (Some result) hd ((DelayedDotLookup (longId, expr.RangeWithoutAnyExtraDot)) :: delayed)

Expand Down Expand Up @@ -8489,7 +8489,7 @@ and GetLongIdentTypeNameInfo delayed =
| _ ->
TypeNameResolutionInfo.Default

and TcLongIdentThen cenv (overallTy: OverallTy) env tpenv (LongIdentWithDots(longId, _)) delayed =
and TcLongIdentThen cenv (overallTy: OverallTy) env tpenv (SynLongIdent(longId, _, _)) delayed =

let ad = env.eAccessRights
let typeNameResInfo = GetLongIdentTypeNameInfo delayed
Expand Down Expand Up @@ -10114,7 +10114,7 @@ and CheckRecursiveBindingIds binds =
match b with
| SynPat.Named(SynIdent(id,_), _, _, _)
| SynPat.As(_, SynPat.Named(SynIdent(id,_), _, _, _), _)
| SynPat.LongIdent(longDotId=LongIdentWithDots([id], _)) -> id.idText
| SynPat.LongIdent(longDotId=SynLongIdent([id], _, _)) -> id.idText
| _ -> ""
if nm <> "" && not (hashOfBinds.Add nm) then
error(Duplicate("value", nm, m))
Expand Down Expand Up @@ -10641,7 +10641,7 @@ and TcAttributeEx canFail cenv (env: TcEnv) attrTgt attrEx (synAttr: SynAttribut

let g = cenv.g

let (LongIdentWithDots(tycon, _)) = synAttr.TypeName
let (SynLongIdent(tycon, _, _)) = synAttr.TypeName
let arg = synAttr.ArgExpr
let targetIndicator = synAttr.Target
let isAppliedToGetterOrSetter = synAttr.AppliesToGetterAndSetter
Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/SyntaxTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ let (|LongOrSingleIdent|_|) inp =

let (|SingleIdent|_|) inp =
match inp with
| SynExpr.LongIdent (false, LongIdentWithDots([id], _), None, _) -> Some id
| SynExpr.LongIdent (false, SynLongIdent([id], _, _), None, _) -> Some id
| SynExpr.Ident id -> Some id
| _ -> None

Expand Down Expand Up @@ -171,7 +171,7 @@ let mkSynPatMaybeVar lidwd vis m = SynPat.LongIdent (lidwd, None, None, None, S
/// Extract the argument for patterns corresponding to the declaration of 'new ... = ...'
let (|SynPatForConstructorDecl|_|) x =
match x with
| SynPat.LongIdent (longDotId=LongIdentWithDots([_], _); argPats=SynArgPats.Pats [arg]) -> Some arg
| SynPat.LongIdent (longDotId=SynLongIdent([_], _, _); argPats=SynArgPats.Pats [arg]) -> Some arg
| _ -> None

/// Recognize the '()' in 'new()'
Expand Down Expand Up @@ -225,7 +225,7 @@ let rec SimplePatOfPat (synArgNameGenerator: SynArgNameGenerator) p =
let m = p.Range
let isCompGen, altNameRefCell, id, item =
match p with
| SynPat.LongIdent(longDotId=LongIdentWithDots([id], _); typarDecls=None; argPats=SynArgPats.Pats []; accessibility=None) ->
| SynPat.LongIdent(longDotId=SynLongIdent([id], _, _); typarDecls=None; argPats=SynArgPats.Pats []; accessibility=None) ->
// The pattern is 'V' or some other capitalized identifier.
// It may be a real variable, in which case we want to maintain its name.
// But it may also be a nullary union case or some other identifier.
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/service/ServiceInterfaceStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type InterfaceData =
Some ("'" + s.idText)
| TyparStaticReq.HeadType ->
Some ("^" + s.idText)
| SynType.LongIdent(LongIdentWithDots(xs, _)) ->
| SynType.LongIdent(SynLongIdent(xs, _, _)) ->
xs |> Seq.map (fun x -> x.idText) |> String.concat "." |> Some
| SynType.App(t, _, ts, _, _, isPostfix, _) ->
match t, ts with
Expand Down Expand Up @@ -503,7 +503,7 @@ module InterfaceStubGenerator =
GetInterfaceMembers entity |> Seq.isEmpty

let internal (|LongIdentPattern|_|) = function
| SynPat.LongIdent(longDotId=LongIdentWithDots(xs, _)) ->
| SynPat.LongIdent(longDotId=SynLongIdent(xs, _, _)) ->
// let (name, range) = xs |> List.map (fun x -> x.idText, x.idRange) |> List.last
let last = List.last xs
Some(last.idText, last.idRange)
Expand Down
8 changes: 4 additions & 4 deletions src/fsharp/service/ServiceNavigation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ module NavigationImpl =
| _ -> synExpr.Range

match synPat, memberOpt with
| SynPat.LongIdent(longDotId=LongIdentWithDots(lid,_); accessibility=access), Some(flags) when isMember ->
| SynPat.LongIdent(longDotId=SynLongIdent(lid,_,_); accessibility=access), Some(flags) when isMember ->
let icon, kind =
match flags.MemberKind with
| SynMemberKind.ClassConstructor
Expand All @@ -158,7 +158,7 @@ module NavigationImpl =
| hd :: _ -> (lid, hd.idRange)
| _ -> (lid, m)
[ createMemberLid(lidShow, kind, icon, unionRanges rangeMerge m, enclosingEntityKind, isAbstract, access) ]
| SynPat.LongIdent(longDotId=LongIdentWithDots(lid,_); accessibility=access), _ ->
| SynPat.LongIdent(longDotId=SynLongIdent(lid,_,_); accessibility=access), _ ->
[ createMemberLid(lid, NavigationItemKind.Field, FSharpGlyph.Field, unionRanges (List.head lid).idRange m, enclosingEntityKind, isAbstract, access) ]
| SynPat.Named (SynIdent(id,_), _, access, _), _ | SynPat.As(_, SynPat.Named (SynIdent(id,_), _, access, _), _), _ ->
let glyph = if isMember then FSharpGlyph.Method else FSharpGlyph.Field
Expand Down Expand Up @@ -574,10 +574,10 @@ module NavigateTo =
| _ -> NavigableItemKind.ModuleValue

match headPat with
| SynPat.LongIdent(longDotId=LongIdentWithDots([_; id], _)) ->
| SynPat.LongIdent(longDotId=SynLongIdent([_; id], _,_)) ->
// instance members
addIdent kind id false container
| SynPat.LongIdent(longDotId=LongIdentWithDots([id], _)) ->
| SynPat.LongIdent(longDotId=SynLongIdent([id], _,_)) ->
// functions
addIdent kind id false container
| SynPat.Named (SynIdent(id,_), _, _, _) | SynPat.As(_, SynPat.Named (SynIdent(id,_), _, _, _), _) ->
Expand Down
15 changes: 7 additions & 8 deletions src/fsharp/service/ServiceParamInfoLocations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ open FSharp.Compiler.Text
open FSharp.Compiler.Text.Position
open FSharp.Compiler.Text.Range
open FSharp.Compiler.Syntax
open FSharp.Compiler.SyntaxTrivia
open FSharp.Compiler.SyntaxTreeOps

type TupledArgumentLocation = { IsNamedArgument: bool; ArgumentRange: range }
Expand Down Expand Up @@ -61,8 +60,8 @@ module internal ParameterLocationsImpl =
match synExpr with
| SynExpr.Ident id -> Some ([id.idText], id.idRange)
| SynExpr.LongIdent(_, SynLongIdent([id], [], [ Some _ ]), _, _) -> Some ([id.idText], id.idRange)
| SynExpr.LongIdent (_, LongIdentWithDots(lid, _), _, lidRange)
| SynExpr.DotGet (_, _, LongIdentWithDots(lid, _), lidRange) -> Some (pathOfLid lid, lidRange)
| SynExpr.LongIdent (_, SynLongIdent(lid, _, _), _, lidRange)
| SynExpr.DotGet (_, _, SynLongIdent(lid, _, _), lidRange) -> Some (pathOfLid lid, lidRange)
| SynExpr.TypeApp (synExpr, _, _synTypeList, _commas, _, _, _range) -> digOutIdentFromFuncExpr synExpr
| SynExpr.Paren(expr = expr) -> digOutIdentFromFuncExpr expr
| _ -> None
Expand All @@ -73,8 +72,8 @@ module internal ParameterLocationsImpl =

let digOutIdentFromStaticArg (StripParenTypes synType) =
match synType with
| SynType.StaticConstantNamed(SynType.LongIdent(LongIdentWithDots([id], _)), _, _) -> Some id.idText
| SynType.LongIdent(LongIdentWithDots([id], _)) -> Some id.idText // NOTE: again, not a static constant, but may be a prefix of a Named in incomplete code
| SynType.StaticConstantNamed(SynType.LongIdent(SynLongIdent([id], _, _)), _, _) -> Some id.idText
| SynType.LongIdent(SynLongIdent([id], _, _)) -> Some id.idText // NOTE: again, not a static constant, but may be a prefix of a Named in incomplete code
| _ -> None

let getNamedParamName e =
Expand All @@ -90,13 +89,13 @@ module internal ParameterLocationsImpl =
| SynExpr.App (ExprAtomicFlag.NonAtomic, _,
SynExpr.App (ExprAtomicFlag.NonAtomic, true,
SynExpr.LongIdent(longDotId = SynLongIdent(id = [op])),
SynExpr.LongIdent (true(*isOptional*), LongIdentWithDots([n], _), _ref, _lidrange), _range),
SynExpr.LongIdent (true(*isOptional*), SynLongIdent([n], _, _), _ref, _lidrange), _range),
_, _) when op.idText="op_Equality" -> Some n.idText
| _ -> None

let getTypeName synType =
match synType with
| SynType.LongIdent(LongIdentWithDots(ids, _)) -> ids |> pathOfLid
| SynType.LongIdent(SynLongIdent(ids, _, _)) -> ids |> pathOfLid
| _ -> [""] // TODO type name for other cases, see also unit test named "ParameterInfo.LocationOfParams.AfterQuicklyTyping.CallConstructorViaLongId.Bug94333"

let handleSingleArg traverseSynExpr (pos, synExpr, parenRange, rpRangeOpt : _ option) =
Expand Down Expand Up @@ -171,7 +170,7 @@ module internal ParameterLocationsImpl =

let (|StaticParameters|_|) pos (StripParenTypes synType) =
match synType with
| SynType.App(StripParenTypes (SynType.LongIdent(LongIdentWithDots(lid, _) as lidwd)), Some(openm), args, commas, closemOpt, _pf, wholem) ->
| SynType.App(StripParenTypes (SynType.LongIdent(SynLongIdent(lid, _, _) as lidwd)), Some(openm), args, commas, closemOpt, _pf, wholem) ->
let lidm = lidwd.Range
let betweenTheBrackets = mkRange wholem.FileName openm.Start wholem.End
if SyntaxTraversal.rangeContainsPosEdgesExclusive betweenTheBrackets pos && args |> List.forall isStaticArg then
Expand Down
Loading