Skip to content

Commit

Permalink
Include star in topTupleType rule. (#13621)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Aug 8, 2022
1 parent 1aefc2f commit f8b56cb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -5030,7 +5030,8 @@ topType:
topTupleType:
| topAppType STAR topTupleTypeElements
{ let t, argInfo = $1
let path = SynTupleTypeSegment.Type t :: (List.map fst $3)
let mStar = rhs parseState 2
let path = SynTupleTypeSegment.Type t :: SynTupleTypeSegment.Star mStar :: (List.map fst $3)
let mdata = argInfo :: (List.choose snd $3)
mkSynTypeTuple false path, mdata }

Expand Down
32 changes: 32 additions & 0 deletions tests/service/SyntaxTreeTests/BindingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,35 @@ let a =
]) ])) ->
assertRange (3, 4) (3, 7) mLet
| _ -> Assert.Fail "Could not get valid AST"

[<Test>]
let ``Tuple return type of binding should contain stars`` () =
let parseResults =
getParseResults """
let a : int * string = failwith "todo"
let b : int * string * bool = 1, "", false
"""

match parseResults with
| ParsedInput.ImplFile (ParsedImplFileInput (modules = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [
SynModuleDecl.Let(bindings = [
SynBinding(returnInfo =
Some (SynBindingReturnInfo(typeName = SynType.Tuple(path = [
SynTupleTypeSegment.Type _
SynTupleTypeSegment.Star _
SynTupleTypeSegment.Type _
]))))
])
SynModuleDecl.Let(bindings = [
SynBinding(returnInfo =
Some (SynBindingReturnInfo(typeName = SynType.Tuple(path = [
SynTupleTypeSegment.Type _
SynTupleTypeSegment.Star _
SynTupleTypeSegment.Type _
SynTupleTypeSegment.Star _
SynTupleTypeSegment.Type _
]))))
])
]) ])) ->
Assert.Pass ()
| _ -> Assert.Fail $"Could not get valid AST, got {parseResults}"

0 comments on commit f8b56cb

Please sign in to comment.