-
Notifications
You must be signed in to change notification settings - Fork 833
Fix a few AND operator parser bugs and regressions #17113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ecce461
Fix pattern matching parser regression
psfinaki bc2546a
Update 8.0.400.md
psfinaki c921da9
bring back precedences
psfinaki 70521ee
More tests
psfinaki cd6bee8
More tests
psfinaki 221f2f7
Merge branch 'main' into fix-16447
KevinRansom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.