-
Notifications
You must be signed in to change notification settings - Fork 793
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a few AND operator parser bugs and regressions (#17113)
- Loading branch information
Showing
48 changed files
with
1,055 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern04.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// #Conformance #PatternMatching #PatternMatchingGuards | ||
|
||
open System | ||
|
||
let x: Result<unit, exn> = Error (NullReferenceException()) | ||
|
||
match x with | ||
| Error (_: exn & :? NullReferenceException) -> printfn "NullRef" | ||
| _ -> () | ||
|
||
match x with | ||
| Error (_: exn & (:? NullReferenceException)) -> printfn "NullRef" | ||
| _ -> () | ||
|
||
match x with | ||
| Error ((_: exn) & :? NullReferenceException) -> printfn "NullRef" | ||
| _ -> () | ||
|
||
match x with | ||
| Error ((_: exn) & (:? NullReferenceException)) -> printfn "NullRef" | ||
| _ -> () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns09.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// #Conformance #PatternMatching #ActivePatterns | ||
#light | ||
|
||
// Verify AND on active patterns with exceptions | ||
|
||
let (_ : exn & Failure _ | _) = exn () | ||
let ((_ : exn) & (Failure _) | (_)) = exn () | ||
let (_ : exn & (Failure _) | _) = exn () | ||
let ((_ : exn) & Failure _ | (_)) = exn () | ||
|
||
exception MyExn | ||
|
||
let (_ : exn & MyExn | _) = exn () | ||
let ((_ : exn) & (MyExn) | (_)) = exn () | ||
let (_ : exn & (MyExn) | _) = exn () | ||
let ((_ : exn) & MyExn | (_)) = exn () | ||
|
||
exit 0 |
18 changes: 18 additions & 0 deletions
18
tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns10.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// #Conformance #PatternMatching #ActivePatterns | ||
#light | ||
|
||
// Verify AND on incomplete active patterns with exceptions | ||
|
||
let (_ : exn & Failure _) = exn () | ||
let ((_ : exn) & Failure _) = exn () | ||
let (_ : exn & (Failure _)) = exn () | ||
let ((_ : exn) & (Failure _)) = exn () | ||
|
||
exception MyExn | ||
|
||
let (_ : exn & MyExn) = exn () | ||
let ((_ : exn) & MyExn) = exn () | ||
let (_ : exn & (MyExn)) = exn () | ||
let ((_ : exn) & (MyExn)) = exn () | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let (_ : exn & Failure _) = exn () |
34 changes: 34 additions & 0 deletions
34
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs.bsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
ImplFile | ||
(ParsedImplFileInput | ||
("/root/OperatorName/ActivePatternAnd 01.fs", false, | ||
QualifiedNameOfFile ActivePatternAnd 01, [], [], | ||
[SynModuleOrNamespace | ||
([ActivePatternAnd 01], false, AnonModule, | ||
[Let | ||
(false, | ||
[SynBinding | ||
(None, Normal, false, false, [], | ||
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), | ||
SynValData | ||
(None, SynValInfo ([], SynArgInfo ([], false, None)), None), | ||
Paren | ||
(Ands | ||
([Typed | ||
(Wild (1,5--1,6), | ||
LongIdent (SynLongIdent ([exn], [], [None])), | ||
(1,5--1,12)); | ||
LongIdent | ||
(SynLongIdent ([Failure], [], [None]), None, None, | ||
Pats [Wild (1,23--1,24)], None, (1,15--1,24))], | ||
(1,5--1,24)), (1,4--1,25)), None, | ||
App | ||
(NonAtomic, false, Ident exn, Const (Unit, (1,32--1,34)), | ||
(1,28--1,34)), (1,4--1,25), Yes (1,0--1,34), | ||
{ LeadingKeyword = Let (1,0--1,3) | ||
InlineKeyword = None | ||
EqualsRange = Some (1,26--1,27) })], (1,0--1,34))], | ||
PreXmlDocEmpty, [], None, (1,0--1,34), { LeadingKeyword = None })], | ||
(true, true), { ConditionalDirectives = [] | ||
CodeComments = [] }, set [])) | ||
|
||
(1,0)-(1,34) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 01' based on the file name 'ActivePatternAnd 01.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file. |
1 change: 1 addition & 0 deletions
1
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let ((_ : exn) & Failure _) = exn () |
35 changes: 35 additions & 0 deletions
35
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs.bsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ImplFile | ||
(ParsedImplFileInput | ||
("/root/OperatorName/ActivePatternAnd 02.fs", false, | ||
QualifiedNameOfFile ActivePatternAnd 02, [], [], | ||
[SynModuleOrNamespace | ||
([ActivePatternAnd 02], false, AnonModule, | ||
[Let | ||
(false, | ||
[SynBinding | ||
(None, Normal, false, false, [], | ||
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), | ||
SynValData | ||
(None, SynValInfo ([], SynArgInfo ([], false, None)), None), | ||
Paren | ||
(Ands | ||
([Paren | ||
(Typed | ||
(Wild (1,6--1,7), | ||
LongIdent (SynLongIdent ([exn], [], [None])), | ||
(1,6--1,13)), (1,5--1,14)); | ||
LongIdent | ||
(SynLongIdent ([Failure], [], [None]), None, None, | ||
Pats [Wild (1,25--1,26)], None, (1,17--1,26))], | ||
(1,5--1,26)), (1,4--1,27)), None, | ||
App | ||
(NonAtomic, false, Ident exn, Const (Unit, (1,34--1,36)), | ||
(1,30--1,36)), (1,4--1,27), Yes (1,0--1,36), | ||
{ LeadingKeyword = Let (1,0--1,3) | ||
InlineKeyword = None | ||
EqualsRange = Some (1,28--1,29) })], (1,0--1,36))], | ||
PreXmlDocEmpty, [], None, (1,0--1,36), { LeadingKeyword = None })], | ||
(true, true), { ConditionalDirectives = [] | ||
CodeComments = [] }, set [])) | ||
|
||
(1,0)-(1,36) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 02' based on the file name 'ActivePatternAnd 02.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file. |
1 change: 1 addition & 0 deletions
1
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let (_ : exn & (Failure _)) = exn () |
35 changes: 35 additions & 0 deletions
35
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs.bsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ImplFile | ||
(ParsedImplFileInput | ||
("/root/OperatorName/ActivePatternAnd 03.fs", false, | ||
QualifiedNameOfFile ActivePatternAnd 03, [], [], | ||
[SynModuleOrNamespace | ||
([ActivePatternAnd 03], false, AnonModule, | ||
[Let | ||
(false, | ||
[SynBinding | ||
(None, Normal, false, false, [], | ||
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), | ||
SynValData | ||
(None, SynValInfo ([], SynArgInfo ([], false, None)), None), | ||
Paren | ||
(Ands | ||
([Typed | ||
(Wild (1,5--1,6), | ||
LongIdent (SynLongIdent ([exn], [], [None])), | ||
(1,5--1,12)); | ||
Paren | ||
(LongIdent | ||
(SynLongIdent ([Failure], [], [None]), None, None, | ||
Pats [Wild (1,24--1,25)], None, (1,16--1,25)), | ||
(1,15--1,26))], (1,5--1,26)), (1,4--1,27)), None, | ||
App | ||
(NonAtomic, false, Ident exn, Const (Unit, (1,34--1,36)), | ||
(1,30--1,36)), (1,4--1,27), Yes (1,0--1,36), | ||
{ LeadingKeyword = Let (1,0--1,3) | ||
InlineKeyword = None | ||
EqualsRange = Some (1,28--1,29) })], (1,0--1,36))], | ||
PreXmlDocEmpty, [], None, (1,0--1,36), { LeadingKeyword = None })], | ||
(true, true), { ConditionalDirectives = [] | ||
CodeComments = [] }, set [])) | ||
|
||
(1,0)-(1,36) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 03' based on the file name 'ActivePatternAnd 03.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file. |
1 change: 1 addition & 0 deletions
1
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let ((_ : exn) & (Failure _)) = exn () |
36 changes: 36 additions & 0 deletions
36
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs.bsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
ImplFile | ||
(ParsedImplFileInput | ||
("/root/OperatorName/ActivePatternAnd 04.fs", false, | ||
QualifiedNameOfFile ActivePatternAnd 04, [], [], | ||
[SynModuleOrNamespace | ||
([ActivePatternAnd 04], false, AnonModule, | ||
[Let | ||
(false, | ||
[SynBinding | ||
(None, Normal, false, false, [], | ||
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), | ||
SynValData | ||
(None, SynValInfo ([], SynArgInfo ([], false, None)), None), | ||
Paren | ||
(Ands | ||
([Paren | ||
(Typed | ||
(Wild (1,6--1,7), | ||
LongIdent (SynLongIdent ([exn], [], [None])), | ||
(1,6--1,13)), (1,5--1,14)); | ||
Paren | ||
(LongIdent | ||
(SynLongIdent ([Failure], [], [None]), None, None, | ||
Pats [Wild (1,26--1,27)], None, (1,18--1,27)), | ||
(1,17--1,28))], (1,5--1,28)), (1,4--1,29)), None, | ||
App | ||
(NonAtomic, false, Ident exn, Const (Unit, (1,36--1,38)), | ||
(1,32--1,38)), (1,4--1,29), Yes (1,0--1,38), | ||
{ LeadingKeyword = Let (1,0--1,3) | ||
InlineKeyword = None | ||
EqualsRange = Some (1,30--1,31) })], (1,0--1,38))], | ||
PreXmlDocEmpty, [], None, (1,0--1,38), { LeadingKeyword = None })], | ||
(true, true), { ConditionalDirectives = [] | ||
CodeComments = [] }, set [])) | ||
|
||
(1,0)-(1,38) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 04' based on the file name 'ActivePatternAnd 04.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file. |
1 change: 1 addition & 0 deletions
1
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let (_ : exn & Failure _ | _) = exn () |
36 changes: 36 additions & 0 deletions
36
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs.bsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
ImplFile | ||
(ParsedImplFileInput | ||
("/root/OperatorName/ActivePatternAnd 05.fs", false, | ||
QualifiedNameOfFile ActivePatternAnd 05, [], [], | ||
[SynModuleOrNamespace | ||
([ActivePatternAnd 05], false, AnonModule, | ||
[Let | ||
(false, | ||
[SynBinding | ||
(None, Normal, false, false, [], | ||
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), | ||
SynValData | ||
(None, SynValInfo ([], SynArgInfo ([], false, None)), None), | ||
Paren | ||
(Or | ||
(Ands | ||
([Typed | ||
(Wild (1,5--1,6), | ||
LongIdent (SynLongIdent ([exn], [], [None])), | ||
(1,5--1,12)); | ||
LongIdent | ||
(SynLongIdent ([Failure], [], [None]), None, None, | ||
Pats [Wild (1,23--1,24)], None, (1,15--1,24))], | ||
(1,5--1,24)), Wild (1,27--1,28), (1,5--1,28), | ||
{ BarRange = (1,25--1,26) }), (1,4--1,29)), None, | ||
App | ||
(NonAtomic, false, Ident exn, Const (Unit, (1,36--1,38)), | ||
(1,32--1,38)), (1,4--1,29), Yes (1,0--1,38), | ||
{ LeadingKeyword = Let (1,0--1,3) | ||
InlineKeyword = None | ||
EqualsRange = Some (1,30--1,31) })], (1,0--1,38))], | ||
PreXmlDocEmpty, [], None, (1,0--1,38), { LeadingKeyword = None })], | ||
(true, true), { ConditionalDirectives = [] | ||
CodeComments = [] }, set [])) | ||
|
||
(1,0)-(1,38) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 05' based on the file name 'ActivePatternAnd 05.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file. |
1 change: 1 addition & 0 deletions
1
tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let ((_ : exn) & (Failure _) | (_)) = exn () |
Oops, something went wrong.