Skip to content

Commit

Permalink
Include firstType when used on Services and fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp committed Jul 18, 2022
1 parent dfd8f29 commit 341050b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Compiler/Service/ServiceParseTreeWalk.fs
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ module SyntaxTraversal =
| SynType.Array (_, ty, _) -> traverseSynType path ty
| SynType.StaticConstantNamed (ty1, ty2, _)
| SynType.MeasureDivide (ty1, ty2, _) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path)
| SynType.Tuple(_, _, _, elements, _) -> elements |> List.map snd |> List.tryPick (traverseSynType path)
| SynType.Tuple (_, _, firstType, tys, _) -> firstType :: (List.map snd tys) |> List.tryPick (traverseSynType path)
| SynType.StaticConstantExpr (expr, _) -> traverseSynExpr [] expr
| SynType.Anon _ -> None
| _ -> None
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ module ParsedInput =
None
| SynType.App (ty, _, types, _, _, _, _) -> walkType ty |> Option.orElseWith (fun () -> List.tryPick walkType types)
| SynType.LongIdentApp (_, _, _, types, _, _, _) -> List.tryPick walkType types
| SynType.Tuple(_, _, _, elements, _) -> elements |> List.tryPick (fun (_, t) -> walkType t)
| SynType.Tuple (_, _, firstType, tys, _) -> firstType :: (List.map snd tys) |> List.tryPick (fun t -> walkType t)
| SynType.Array (_, t, _) -> walkType t
| SynType.Fun (argType = t1; returnType = t2) -> walkType t1 |> Option.orElseWith (fun () -> walkType t2)
| SynType.WithGlobalConstraints (t, _, _) -> walkType t
Expand Down Expand Up @@ -1669,7 +1669,7 @@ module ParsedInput =
walkType ty
List.iter walkType types
| SynType.LongIdentApp (_, _, _, types, _, _, _) -> List.iter walkType types
| SynType.Tuple(_, _, _, elements, _) -> elements |> List.iter (fun (_, t) -> walkType t)
| SynType.Tuple (_, _, firstType, tys, _) -> firstType :: (List.map snd tys) |> List.iter (fun t -> walkType t)
| SynType.WithGlobalConstraints (t, typeConstraints, _) ->
walkType t
List.iter walkTypeConstraint typeConstraints
Expand Down
9 changes: 5 additions & 4 deletions src/Compiler/SyntaxTree/ParseHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -816,14 +816,15 @@ let mkSynMemberDefnGetSet
let mkTupleOrDivide (isStruct: bool) (leadingType: SynType) (isStar: bool) (elementTypes: (bool * SynType) list) : SynType =
// x * y
let range =
(leadingType.Range, elementTypes) ||> List.fold (fun acc (_, t) -> unionRanges acc t.Range)

(leadingType.Range, elementTypes)
||> List.fold (fun acc (_, t) -> unionRanges acc t.Range)

let newElementTypes =
elementTypes
|> List.fold (fun (lastIsStar, currentList) (isStar , t) -> (isStar, (lastIsStar, t) :: currentList)) (isStar, [])
|> List.fold (fun (lastIsStar, currentList) (isStar, t) -> (isStar, (lastIsStar, t) :: currentList)) (isStar, [])
|> snd
|> List.rev

SynType.Tuple(isStruct, false, leadingType, newElementTypes, range)

let mkDivideWithLeadingSlash (_: (bool * SynType) list) : SynType = failwith "TODO"
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ type SynType =
greaterRange: range option *
range: range

| Tuple of isStruct:bool * hasLeadingSlash:bool * firstType:SynType * elements: (bool * SynType) list * range: range
| Tuple of isStruct: bool * hasLeadingSlash: bool * firstType: SynType * elements: (bool * SynType) list * range: range

| AnonRecd of isStruct: bool * fields: (Ident * SynType) list * range: range

Expand Down
7 changes: 6 additions & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,12 @@ type SynType =

/// F# syntax: type * ... * type
/// F# syntax: struct (type * ... * type)
| Tuple of isStruct:bool * hasLeadingSlash:bool * firstType:SynType * elements: (bool * SynType) list * range: range
| Tuple of
isStruct: bool *
hasLeadingSlash: bool *
firstType: SynType *
elements: (bool * SynType) list *
range: range

/// F# syntax: {| id: type; ...; id: type |}
/// F# syntax: struct {| id: type; ...; id: type |}
Expand Down

0 comments on commit 341050b

Please sign in to comment.