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
35 changes: 16 additions & 19 deletions src/fsharp/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ let rangeOfLongIdent(lid:LongIdent) =
%type <ParsedScriptInteraction> interaction
%type <Ident> ident
%type <SynType> typ typEOF
%type <SynTypeDefnSig list> tyconSpfns
%type <SynTypeDefnSig list> tyconSpfnList
%type <SynExpr> patternResult
%type <SynExpr> declExpr
%type <SynExpr> minusExpr
Expand Down Expand Up @@ -810,18 +810,21 @@ moduleSpfn:
let m = (rhs2 parseState 1 4, $5) ||> unionRangeWithListBy (fun (d: SynModuleSigDecl) -> d.Range)
SynModuleSigDecl.NestedModule(info, isRec, $5, m) }

| opt_attributes opt_declVisibility tyconSpfns
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2))
let (SynTypeDefnSig(SynComponentInfo(cas, a, cs, b, c, d, d2, d3), e, f, g)), rest =
match $3 with
| [] -> raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsUnexpectedEmptyModuleDefn())
| h :: t -> h, t
let attrs = $1@cas
let mTc = (g, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range)
let tc = (SynTypeDefnSig(SynComponentInfo(attrs, a, cs, b, c, d, d2, d3), e, f, mTc))
let lastType = List.tryLast rest |> Option.defaultValue tc |> fun t -> t.Range
let m = mkRange lastType.FileName mTc.Start lastType.End
SynModuleSigDecl.Types (tc :: rest, m) }
| opt_attributes opt_declVisibility typeKeyword tyconSpfnList
{ if Option.isSome $2 then
errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2))

match $4 with
| [] -> raiseParseErrorAt (rhs2 parseState 3 4) (FSComp.SR.parsUnexpectedEmptyModuleDefn ())
| SynTypeDefnSig (SynComponentInfo (cas, a, cs, b, c, d, d2, d3), e, f, g) :: tail ->
let attrs = $1 @ cas
let mTc =
let keywordM = rhs parseState 3
(keywordM, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) |> unionRanges g
let tc = (SynTypeDefnSig(SynComponentInfo(attrs, a, cs, b, c, d, d2, d3), e, f, mTc))
let m = (mTc, tail) ||> unionRangeWithListBy (fun (a: SynTypeDefnSig) -> a.Range)

SynModuleSigDecl.Types (tc :: tail, m) }

| opt_attributes opt_declVisibility exconSpfn
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2))
Expand Down Expand Up @@ -870,12 +873,6 @@ moduleSpecBlock:
{ $2 }


/* A group of type definitions in a signature */
tyconSpfns:
| typeKeyword tyconSpfnList
{ $2 }


tyconSpfnList:
| tyconSpfn AND tyconSpfnList
{ $1 :: $3 }
Expand Down
14 changes: 7 additions & 7 deletions tests/service/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ type Meh =
match parseResults with
| ParsedInput.SigFile (ParsedSigFileInput (modules = [
SynModuleOrNamespaceSig(decls = [SynModuleSigDecl.Types(range = r)]) ])) ->
assertRange (3, 5) (5,11) r
assertRange (3, 0) (5,11) r
| _ -> Assert.Fail "Could not get valid AST"

[<Test>]
Expand All @@ -653,7 +653,7 @@ type MyRecord =
match parseResults with
| ParsedInput.SigFile (ParsedSigFileInput (modules = [
SynModuleOrNamespaceSig(decls = [SynModuleSigDecl.Types(types = [SynTypeDefnSig.SynTypeDefnSig(range = r)])]) ])) ->
assertRange (2, 5) (4, 30) r
assertRange (2, 0) (4, 30) r
| _ -> Assert.Fail "Could not get valid AST"

[<Test>]
Expand All @@ -669,7 +669,7 @@ type MyRecord =
match parseResults with
| ParsedInput.SigFile (ParsedSigFileInput (modules = [
SynModuleOrNamespaceSig(decls = [SynModuleSigDecl.Types(types = [SynTypeDefnSig.SynTypeDefnSig(range = r)])]) ])) ->
assertRange (2, 5) (5, 30) r
assertRange (2, 0) (5, 30) r
| _ -> Assert.Fail "Could not get valid AST"

[<Test>]
Expand All @@ -683,7 +683,7 @@ type MyFunction =
match parseResults with
| ParsedInput.SigFile (ParsedSigFileInput (modules = [
SynModuleOrNamespaceSig(decls = [SynModuleSigDecl.Types(types = [SynTypeDefnSig.SynTypeDefnSig(range = r)])]) ])) ->
assertRange (2, 5) (3, 29) r
assertRange (2, 0) (3, 29) r
| _ -> Assert.Fail "Could not get valid AST"

[<Test>]
Expand All @@ -698,7 +698,7 @@ type SomeCollection with
match parseResults with
| ParsedInput.SigFile (ParsedSigFileInput (modules = [
SynModuleOrNamespaceSig(decls = [SynModuleSigDecl.Types(types = [SynTypeDefnSig.SynTypeDefnSig(range = r)])]) ])) ->
assertRange (2, 5) (4, 37) r
assertRange (2, 0) (4, 37) r
| _ -> Assert.Fail "Could not get valid AST"

[<Test>]
Expand Down Expand Up @@ -745,9 +745,9 @@ and [<CustomEquality>] Bang =
SynTypeDefnSig.SynTypeDefnSig(range = r1)
SynTypeDefnSig.SynTypeDefnSig(range = r2)
]) as t]) ])) ->
assertRange (4, 5) (5, 9) r1
assertRange (4, 0) (5, 9) r1
assertRange (7, 4) (12, 42) r2
assertRange (4, 5) (12, 42) t.Range
assertRange (4, 0) (12, 42) t.Range
| _ -> Assert.Fail "Could not get valid AST"

[<Test>]
Expand Down