Skip to content

Commit 50e4710

Browse files
committed
Fix error range, add missing error production
1 parent 0f0b1e5 commit 50e4710

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

src/Compiler/pars.fsy

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,13 +2407,25 @@ attrUnionCaseDecl:
24072407
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
24082408
let mOf = rhs parseState 3
24092409
let mId = mOf.StartRange
2410-
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mId))
2410+
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
24112411
let mDecl = rhs2 parseState 1 4
24122412
(fun (xmlDoc, mBar) ->
24132413
let id = SynIdent(mkSynId mId "", None)
24142414
let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
24152415
let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2416-
Choice2Of2 (SynUnionCase ( $1, id, SynUnionCaseKind.Fields $4, xmlDoc, None, mDecl, trivia))) }
2416+
Choice2Of2(SynUnionCase($1, id, SynUnionCaseKind.Fields $4, xmlDoc, None, mDecl, trivia))) }
2417+
2418+
| opt_attributes opt_access OF recover
2419+
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2420+
let mOf = rhs parseState 3
2421+
let mId = mOf.StartRange
2422+
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
2423+
let mDecl = rhs2 parseState 1 3
2424+
(fun (xmlDoc, mBar) ->
2425+
let id = SynIdent(mkSynId mId "", None)
2426+
let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2427+
let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2428+
Choice2Of2(SynUnionCase($1, id, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }
24172429

24182430
| opt_attributes opt_access unionCaseName OF recover
24192431
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
@@ -2489,7 +2501,7 @@ firstUnionCaseDecl:
24892501
| OF unionCaseRepr
24902502
{ let mOf = rhs parseState 1
24912503
let mId = mOf.StartRange
2492-
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mId))
2504+
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
24932505
let id = SynIdent(mkSynId mId "", None)
24942506
let trivia: SynUnionCaseTrivia = { BarRange = None }
24952507
let xmlDoc = grabXmlDoc (parseState, [], 1)

tests/service/data/SyntaxTree/UnionCase/Missing name 03.fs.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ ImplFile
4646
{ ConditionalDirectives = []
4747
CodeComments = [] }, set []))
4848

49-
(4,4)-(4,4) parse error Missing union case name
49+
(4,4)-(4,6) parse error Missing union case name

tests/service/data/SyntaxTree/UnionCase/Missing name 04.fs.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ ImplFile
4141
{ ConditionalDirectives = []
4242
CodeComments = [] }, set []))
4343

44-
(5,6)-(5,6) parse error Missing union case name
44+
(5,6)-(5,8) parse error Missing union case name

tests/service/data/SyntaxTree/UnionCase/Missing name 05.fs.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ ImplFile
4242
CodeComments = [] }, set []))
4343

4444
(5,6)-(5,14) parse error Accessibility modifiers are not permitted on union cases. Use 'type U = internal ...' or 'type U = private ...' to give an accessibility to the whole representation.
45-
(5,15)-(5,15) parse error Missing union case name
45+
(5,15)-(5,17) parse error Missing union case name

tests/service/data/SyntaxTree/UnionCase/Missing name 06.fs.bsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ImplFile
2020
SynUnionCase
2121
([], SynIdent (, None), Fields [],
2222
PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector),
23-
None, (5,4--5,5), { BarRange = Some (5,4--5,5) });
23+
None, (5,6--5,17), { BarRange = Some (5,4--5,5) });
2424
SynUnionCase
2525
([], SynIdent (C, None), Fields [],
2626
PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector),
@@ -36,3 +36,4 @@ ImplFile
3636

3737
(6,4)-(6,5) parse error Unexpected symbol '|' in union case
3838
(5,6)-(5,14) parse error Accessibility modifiers are not permitted on union cases. Use 'type U = internal ...' or 'type U = private ...' to give an accessibility to the whole representation.
39+
(5,15)-(5,17) parse error Missing union case name

tests/service/data/SyntaxTree/UnionCase/Missing name 07.fs.bsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ImplFile
2020
SynUnionCase
2121
([], SynIdent (, None), Fields [],
2222
PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector),
23-
None, (5,4--5,5), { BarRange = Some (5,4--5,5) });
23+
None, (5,6--5,8), { BarRange = Some (5,4--5,5) });
2424
SynUnionCase
2525
([], SynIdent (C, None), Fields [],
2626
PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector),
@@ -39,3 +39,4 @@ ImplFile
3939
CodeComments = [] }, set []))
4040

4141
(6,4)-(6,5) parse error Unexpected symbol '|' in union case
42+
(5,6)-(5,8) parse error Missing union case name

0 commit comments

Comments
 (0)