From ecce46121c35f78b3c9c0e27096eceff3510b451 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 24 Apr 2024 16:44:13 +0200 Subject: [PATCH 1/5] Fix pattern matching parser regression --- src/Compiler/pars.fsy | 30 +++++----- .../Conformance/PatternMatching/And/And.fs | 7 +++ .../PatternMatching/And/andPattern04.fs | 21 +++++++ .../service/data/SyntaxTree/Pattern/And 01.fs | 6 ++ .../data/SyntaxTree/Pattern/And 01.fs.bsl | 55 ++++++++++++++++++ .../service/data/SyntaxTree/Pattern/And 02.fs | 6 ++ .../data/SyntaxTree/Pattern/And 02.fs.bsl | 57 ++++++++++++++++++ .../service/data/SyntaxTree/Pattern/And 03.fs | 6 ++ .../data/SyntaxTree/Pattern/And 03.fs.bsl | 56 ++++++++++++++++++ .../service/data/SyntaxTree/Pattern/And 04.fs | 6 ++ .../data/SyntaxTree/Pattern/And 04.fs.bsl | 58 +++++++++++++++++++ 11 files changed, 295 insertions(+), 13 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern04.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/And 01.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/And 01.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/And 02.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/And 02.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/And 03.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/And 03.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/And 04.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/And 04.fs.bsl diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 1c77af1e1a3..5212f6697a6 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2558,6 +2558,10 @@ opt_explicitValTyparDecls: | { SynValTyparDecls(None, true) } +hashConstraint: + | HASH atomType + { SynType.HashConstraint($2, lhs parseState) } + /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ opt_typeConstraints: @@ -2579,20 +2583,20 @@ typeConstraints: /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ intersectionConstraints: - | intersectionConstraints AMP atomType %prec prec_no_more_attr_bindings // todo precedence + | intersectionConstraints AMP hashConstraint { let constraints, mAmpersands = $1 + ($3 :: constraints), (rhs parseState 2 :: mAmpersands) } - match $3 with - | SynType.HashConstraint _ -> () - | ty -> errorR(Error(FSComp.SR.parsConstraintIntersectionSyntaxUsedWithNonFlexibleType(), ty.Range)) - + | intersectionConstraints AMP atomType + { let constraints, mAmpersands = $1 + errorR(Error(FSComp.SR.parsConstraintIntersectionSyntaxUsedWithNonFlexibleType(), $3.Range)) ($3 :: constraints), (rhs parseState 2 :: mAmpersands) } - | atomType - { match $1 with - | SynType.HashConstraint _ -> () - | ty -> errorR(Error(FSComp.SR.parsConstraintIntersectionSyntaxUsedWithNonFlexibleType(), ty.Range)) + | hashConstraint + { [ $1 ], [] } + | atomType + { errorR(Error(FSComp.SR.parsConstraintIntersectionSyntaxUsedWithNonFlexibleType(), $1.Range)) [ $1 ], [] } /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ @@ -5993,11 +5997,11 @@ tupleOrQuotTypeElements: { [ SynTupleTypeSegment.Type $1 ] } intersectionType: - | typar AMP intersectionConstraints %prec prec_no_more_attr_bindings // todo precedence + | typar AMP intersectionConstraints { let constraints, mAmpersands = $3 SynType.Intersection(Some $1, List.rev constraints, lhs parseState, { AmpersandRanges = rhs parseState 2 :: List.rev mAmpersands }) } - | atomType AMP intersectionConstraints %prec prec_no_more_attr_bindings // todo precedence + | hashConstraint AMP intersectionConstraints { let constraints, mAmpersands = $3 SynType.Intersection(None, $1 :: List.rev constraints, lhs parseState, { AmpersandRanges = rhs parseState 2 :: List.rev mAmpersands }) } @@ -6213,8 +6217,8 @@ atomTypeOrAnonRecdType: /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ atomType: - | HASH atomType - { SynType.HashConstraint($2, lhs parseState) } + | hashConstraint + { $1 } | appTypeConPower %prec prec_atomtyp_path { $1 } diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs index 596de0187b1..7f46ad02250 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs @@ -34,6 +34,13 @@ module And = |> typecheck |> shouldSucceed + [] + let ``And - andPattern04_fs`` compilation = + compilation + |> asFs + |> typecheck + |> shouldSucceed + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) [] let ``And - E_IdentBoundTwice_fs - --test:ErrorRanges`` compilation = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern04.fs new file mode 100644 index 00000000000..ee196ba07e4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern04.fs @@ -0,0 +1,21 @@ +// #Conformance #PatternMatching #PatternMatchingGuards + +open System + +let x: Result = 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" +| _ -> () diff --git a/tests/service/data/SyntaxTree/Pattern/And 01.fs b/tests/service/data/SyntaxTree/Pattern/And 01.fs new file mode 100644 index 00000000000..eae6846ea1f --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 01.fs @@ -0,0 +1,6 @@ +module Module + +let f x = + match x with + | Error (_: exn & :? System.NullReferenceException) -> () + | _ -> () diff --git a/tests/service/data/SyntaxTree/Pattern/And 01.fs.bsl b/tests/service/data/SyntaxTree/Pattern/And 01.fs.bsl new file mode 100644 index 00000000000..679d264dfcc --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 01.fs.bsl @@ -0,0 +1,55 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/And 01.fs", false, QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([f], [], [None]), None, None, + Pats [Named (SynIdent (x, None), false, None, (3,6--3,7))], + None, (3,4--3,7)), None, + Match + (Yes (4,4--4,16), Ident x, + [SynMatchClause + (LongIdent + (SynLongIdent ([Error], [], [None]), None, None, + Pats + [Paren + (Ands + ([Typed + (Wild (5,13--5,14), + LongIdent + (SynLongIdent ([exn], [], [None])), + (5,13--5,19)); + IsInst + (LongIdent + (SynLongIdent + ([System; NullReferenceException], + [(5,31--5,32)], [None; None])), + (5,22--5,54))], (5,13--5,54)), + (5,12--5,55))], None, (5,6--5,55)), None, + Const (Unit, (5,59--5,61)), (5,6--5,61), Yes, + { ArrowRange = Some (5,56--5,58) + BarRange = Some (5,4--5,5) }); + SynMatchClause + (Wild (6,6--6,7), None, Const (Unit, (6,11--6,13)), + (6,6--6,13), Yes, { ArrowRange = Some (6,8--6,10) + BarRange = Some (6,4--6,5) })], + (4,4--6,13), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,12--4,16) }), (3,4--3,7), + NoneAtLet, { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,8--3,9) })], (3,0--6,13))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/And 02.fs b/tests/service/data/SyntaxTree/Pattern/And 02.fs new file mode 100644 index 00000000000..18ec41f62c6 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 02.fs @@ -0,0 +1,6 @@ +module Module + +let f x = + match x with + | Error (_: exn & (:? System.NullReferenceException)) -> () + | _ -> () diff --git a/tests/service/data/SyntaxTree/Pattern/And 02.fs.bsl b/tests/service/data/SyntaxTree/Pattern/And 02.fs.bsl new file mode 100644 index 00000000000..f533ba83b0a --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 02.fs.bsl @@ -0,0 +1,57 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/And 02.fs", false, QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([f], [], [None]), None, None, + Pats [Named (SynIdent (x, None), false, None, (3,6--3,7))], + None, (3,4--3,7)), None, + Match + (Yes (4,4--4,16), Ident x, + [SynMatchClause + (LongIdent + (SynLongIdent ([Error], [], [None]), None, None, + Pats + [Paren + (Ands + ([Typed + (Wild (5,13--5,14), + LongIdent + (SynLongIdent ([exn], [], [None])), + (5,13--5,19)); + Paren + (IsInst + (LongIdent + (SynLongIdent + ([System; + NullReferenceException], + [(5,32--5,33)], [None; None])), + (5,23--5,55)), (5,22--5,56))], + (5,13--5,56)), (5,12--5,57))], None, + (5,6--5,57)), None, Const (Unit, (5,61--5,63)), + (5,6--5,63), Yes, { ArrowRange = Some (5,58--5,60) + BarRange = Some (5,4--5,5) }); + SynMatchClause + (Wild (6,6--6,7), None, Const (Unit, (6,11--6,13)), + (6,6--6,13), Yes, { ArrowRange = Some (6,8--6,10) + BarRange = Some (6,4--6,5) })], + (4,4--6,13), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,12--4,16) }), (3,4--3,7), + NoneAtLet, { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,8--3,9) })], (3,0--6,13))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/And 03.fs b/tests/service/data/SyntaxTree/Pattern/And 03.fs new file mode 100644 index 00000000000..0f73ae03d95 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 03.fs @@ -0,0 +1,6 @@ +module Module + +let f x = + match x with + | Error ((_: exn) & :? System.NullReferenceException) -> () + | _ -> () diff --git a/tests/service/data/SyntaxTree/Pattern/And 03.fs.bsl b/tests/service/data/SyntaxTree/Pattern/And 03.fs.bsl new file mode 100644 index 00000000000..b75921e2808 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 03.fs.bsl @@ -0,0 +1,56 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/And 03.fs", false, QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([f], [], [None]), None, None, + Pats [Named (SynIdent (x, None), false, None, (3,6--3,7))], + None, (3,4--3,7)), None, + Match + (Yes (4,4--4,16), Ident x, + [SynMatchClause + (LongIdent + (SynLongIdent ([Error], [], [None]), None, None, + Pats + [Paren + (Ands + ([Paren + (Typed + (Wild (5,14--5,15), + LongIdent + (SynLongIdent ([exn], [], [None])), + (5,14--5,20)), (5,13--5,21)); + IsInst + (LongIdent + (SynLongIdent + ([System; NullReferenceException], + [(5,33--5,34)], [None; None])), + (5,24--5,56))], (5,13--5,56)), + (5,12--5,57))], None, (5,6--5,57)), None, + Const (Unit, (5,61--5,63)), (5,6--5,63), Yes, + { ArrowRange = Some (5,58--5,60) + BarRange = Some (5,4--5,5) }); + SynMatchClause + (Wild (6,6--6,7), None, Const (Unit, (6,11--6,13)), + (6,6--6,13), Yes, { ArrowRange = Some (6,8--6,10) + BarRange = Some (6,4--6,5) })], + (4,4--6,13), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,12--4,16) }), (3,4--3,7), + NoneAtLet, { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,8--3,9) })], (3,0--6,13))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/And 04.fs b/tests/service/data/SyntaxTree/Pattern/And 04.fs new file mode 100644 index 00000000000..7a1d9f5e361 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 04.fs @@ -0,0 +1,6 @@ +module Module + +let f x = + match x with + | Error ((_: exn) & (:? System.NullReferenceException)) -> () + | _ -> () diff --git a/tests/service/data/SyntaxTree/Pattern/And 04.fs.bsl b/tests/service/data/SyntaxTree/Pattern/And 04.fs.bsl new file mode 100644 index 00000000000..7a0fa1f4c89 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/And 04.fs.bsl @@ -0,0 +1,58 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/And 04.fs", false, QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([f], [], [None]), None, None, + Pats [Named (SynIdent (x, None), false, None, (3,6--3,7))], + None, (3,4--3,7)), None, + Match + (Yes (4,4--4,16), Ident x, + [SynMatchClause + (LongIdent + (SynLongIdent ([Error], [], [None]), None, None, + Pats + [Paren + (Ands + ([Paren + (Typed + (Wild (5,14--5,15), + LongIdent + (SynLongIdent ([exn], [], [None])), + (5,14--5,20)), (5,13--5,21)); + Paren + (IsInst + (LongIdent + (SynLongIdent + ([System; + NullReferenceException], + [(5,34--5,35)], [None; None])), + (5,25--5,57)), (5,24--5,58))], + (5,13--5,58)), (5,12--5,59))], None, + (5,6--5,59)), None, Const (Unit, (5,63--5,65)), + (5,6--5,65), Yes, { ArrowRange = Some (5,60--5,62) + BarRange = Some (5,4--5,5) }); + SynMatchClause + (Wild (6,6--6,7), None, Const (Unit, (6,11--6,13)), + (6,6--6,13), Yes, { ArrowRange = Some (6,8--6,10) + BarRange = Some (6,4--6,5) })], + (4,4--6,13), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,12--4,16) }), (3,4--3,7), + NoneAtLet, { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,8--3,9) })], (3,0--6,13))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) From bc2546a247257490b7d49bf3afd4b4a7d0c26480 Mon Sep 17 00:00:00 2001 From: Petr Date: Thu, 9 May 2024 16:04:00 +0200 Subject: [PATCH 2/5] Update 8.0.400.md --- docs/release-notes/.FSharp.Compiler.Service/8.0.400.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md index fd28a3c2736..77f479bb3c1 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md @@ -12,6 +12,7 @@ * Fix calling an overridden virtual static method via the interface ([PR #17013](https://github.com/dotnet/fsharp/pull/17013)) * Fix state machines compilation, when big decision trees are involved, by removing code split when resumable code is detected ([PR #17076](https://github.com/dotnet/fsharp/pull/17076)) * Fix for exponential runtime in CE builders when using nested implicit yields [PR #17096](https://github.com/dotnet/fsharp/pull/17096) +* Fix pattern matching parser regression ([Issue #16447](https://github.com/dotnet/fsharp/issues/16447), [PR #17113](https://github.com/dotnet/fsharp/pull/17113)) ### Added From c921da971fa23c89415567e370af00bc152791eb Mon Sep 17 00:00:00 2001 From: Petr Date: Thu, 9 May 2024 16:44:02 +0200 Subject: [PATCH 3/5] bring back precedences --- src/Compiler/pars.fsy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 5212f6697a6..96058711135 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2583,11 +2583,11 @@ typeConstraints: /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ intersectionConstraints: - | intersectionConstraints AMP hashConstraint + | intersectionConstraints AMP hashConstraint %prec prec_no_more_attr_bindings { let constraints, mAmpersands = $1 ($3 :: constraints), (rhs parseState 2 :: mAmpersands) } - | intersectionConstraints AMP atomType + | intersectionConstraints AMP atomType %prec prec_no_more_attr_bindings { let constraints, mAmpersands = $1 errorR(Error(FSComp.SR.parsConstraintIntersectionSyntaxUsedWithNonFlexibleType(), $3.Range)) ($3 :: constraints), (rhs parseState 2 :: mAmpersands) } @@ -5997,11 +5997,11 @@ tupleOrQuotTypeElements: { [ SynTupleTypeSegment.Type $1 ] } intersectionType: - | typar AMP intersectionConstraints + | typar AMP intersectionConstraints %prec prec_no_more_attr_bindings { let constraints, mAmpersands = $3 SynType.Intersection(Some $1, List.rev constraints, lhs parseState, { AmpersandRanges = rhs parseState 2 :: List.rev mAmpersands }) } - | hashConstraint AMP intersectionConstraints + | hashConstraint AMP intersectionConstraints %prec prec_no_more_attr_bindings { let constraints, mAmpersands = $3 SynType.Intersection(None, $1 :: List.rev constraints, lhs parseState, { AmpersandRanges = rhs parseState 2 :: List.rev mAmpersands }) } From 70521ee61726152142426c8991f679ddc5ae9c4f Mon Sep 17 00:00:00 2001 From: Petr Date: Fri, 10 May 2024 16:02:00 +0200 Subject: [PATCH 4/5] More tests --- .../.FSharp.Compiler.Service/8.0.400.md | 2 +- .../PatternMatching/Named/Named.fs | 24 ++++++++++ .../PatternMatching/Named/activePatterns09.fs | 18 +++++++ .../PatternMatching/Named/activePatterns10.fs | 18 +++++++ .../OperatorName/ActivePatternAnd 01.fs | 1 + .../OperatorName/ActivePatternAnd 01.fs.bsl | 34 +++++++++++++ .../OperatorName/ActivePatternAnd 02.fs | 1 + .../OperatorName/ActivePatternAnd 02.fs.bsl | 35 ++++++++++++++ .../OperatorName/ActivePatternAnd 03.fs | 1 + .../OperatorName/ActivePatternAnd 03.fs.bsl | 35 ++++++++++++++ .../OperatorName/ActivePatternAnd 04.fs | 1 + .../OperatorName/ActivePatternAnd 04.fs.bsl | 36 ++++++++++++++ .../OperatorName/ActivePatternAnd 05.fs | 1 + .../OperatorName/ActivePatternAnd 05.fs.bsl | 36 ++++++++++++++ .../OperatorName/ActivePatternAnd 06.fs | 1 + .../OperatorName/ActivePatternAnd 06.fs.bsl | 39 +++++++++++++++ .../OperatorName/ActivePatternAnd 07.fs | 1 + .../OperatorName/ActivePatternAnd 07.fs.bsl | 38 +++++++++++++++ .../OperatorName/ActivePatternAnd 08.fs | 1 + .../OperatorName/ActivePatternAnd 08.fs.bsl | 38 +++++++++++++++ .../ActivePatternExceptionAnd 01.fs | 3 ++ .../ActivePatternExceptionAnd 01.fs.bsl | 43 +++++++++++++++++ .../ActivePatternExceptionAnd 02.fs | 3 ++ .../ActivePatternExceptionAnd 02.fs.bsl | 44 +++++++++++++++++ .../ActivePatternExceptionAnd 03.fs | 3 ++ .../ActivePatternExceptionAnd 03.fs.bsl | 44 +++++++++++++++++ .../ActivePatternExceptionAnd 04.fs | 3 ++ .../ActivePatternExceptionAnd 04.fs.bsl | 45 +++++++++++++++++ .../ActivePatternExceptionAnd 05.fs | 3 ++ .../ActivePatternExceptionAnd 05.fs.bsl | 45 +++++++++++++++++ .../ActivePatternExceptionAnd 06.fs | 3 ++ .../ActivePatternExceptionAnd 06.fs.bsl | 48 +++++++++++++++++++ .../ActivePatternExceptionAnd 07.fs | 3 ++ .../ActivePatternExceptionAnd 07.fs.bsl | 46 ++++++++++++++++++ .../ActivePatternExceptionAnd 08.fs | 3 ++ .../ActivePatternExceptionAnd 08.fs.bsl | 46 ++++++++++++++++++ 36 files changed, 745 insertions(+), 1 deletion(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns09.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns10.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs create mode 100644 tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs.bsl diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md index 77f479bb3c1..11f63225348 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md @@ -12,7 +12,7 @@ * Fix calling an overridden virtual static method via the interface ([PR #17013](https://github.com/dotnet/fsharp/pull/17013)) * Fix state machines compilation, when big decision trees are involved, by removing code split when resumable code is detected ([PR #17076](https://github.com/dotnet/fsharp/pull/17076)) * Fix for exponential runtime in CE builders when using nested implicit yields [PR #17096](https://github.com/dotnet/fsharp/pull/17096) -* Fix pattern matching parser regression ([Issue #16447](https://github.com/dotnet/fsharp/issues/16447), [PR #17113](https://github.com/dotnet/fsharp/pull/17113)) +* Fix several AND operator parser regressions ([Issue #16447](https://github.com/dotnet/fsharp/issues/16447), [Issue #17134](https://github.com/dotnet/fsharp/issues/17134), [PR #17113](https://github.com/dotnet/fsharp/pull/17113)) ### Added diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs index 1b181272a08..5fa8cdc7aa8 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs @@ -87,7 +87,31 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed + + [] + let ``Named - activePatterns09_fs`` compilation = + compilation + |> asFs + |> typecheck + |> shouldSucceed + [] + let ``Named - activePatterns10_fs`` compilation = + compilation + |> asFs + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 6, Col 5, Line 6, Col 26, "Incomplete pattern matches on this expression.") + (Warning 25, Line 7, Col 5, Line 7, Col 28, "Incomplete pattern matches on this expression.") + (Warning 25, Line 8, Col 5, Line 8, Col 28, "Incomplete pattern matches on this expression.") + (Warning 25, Line 9, Col 5, Line 9, Col 30, "Incomplete pattern matches on this expression.") + (Warning 25, Line 13, Col 5, Line 13, Col 22, "Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 14, Col 5, Line 14, Col 24, "Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 15, Col 5, Line 15, Col 24, "Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 16, Col 5, Line 16, Col 26, "Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s).") + ] + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] let ``Named - ActivePatternUnconstrained01_fs - --test:ErrorRanges`` compilation = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns09.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns09.fs new file mode 100644 index 00000000000..0eb679178fd --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns09.fs @@ -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 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns10.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns10.fs new file mode 100644 index 00000000000..1a98c23889e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns10.fs @@ -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 diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs new file mode 100644 index 00000000000..53ffa7e5d43 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs @@ -0,0 +1 @@ +let (_ : exn & Failure _) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs.bsl new file mode 100644 index 00000000000..43d64f45a98 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 01.fs.bsl @@ -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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs new file mode 100644 index 00000000000..01cc92b9412 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs @@ -0,0 +1 @@ +let ((_ : exn) & Failure _) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs.bsl new file mode 100644 index 00000000000..23ebdc7c8da --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 02.fs.bsl @@ -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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs new file mode 100644 index 00000000000..88f4634bd35 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs @@ -0,0 +1 @@ +let (_ : exn & (Failure _)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs.bsl new file mode 100644 index 00000000000..f59e50d9403 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 03.fs.bsl @@ -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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs new file mode 100644 index 00000000000..1e3abce4eae --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs @@ -0,0 +1 @@ +let ((_ : exn) & (Failure _)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs.bsl new file mode 100644 index 00000000000..37b343fad98 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 04.fs.bsl @@ -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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs new file mode 100644 index 00000000000..4c14b8934c3 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs @@ -0,0 +1 @@ +let (_ : exn & Failure _ | _) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs.bsl new file mode 100644 index 00000000000..062a413ccde --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 05.fs.bsl @@ -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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs new file mode 100644 index 00000000000..83fe84e41eb --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs @@ -0,0 +1 @@ +let ((_ : exn) & (Failure _) | (_)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs.bsl new file mode 100644 index 00000000000..7c8649824d5 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 06.fs.bsl @@ -0,0 +1,39 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternAnd 06.fs", false, + QualifiedNameOfFile ActivePatternAnd 06, [], [], + [SynModuleOrNamespace + ([ActivePatternAnd 06], 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 + ([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)), + Paren (Wild (1,32--1,33), (1,31--1,34)), (1,5--1,34), + { BarRange = (1,29--1,30) }), (1,4--1,35)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (1,42--1,44)), + (1,38--1,44)), (1,4--1,35), Yes (1,0--1,44), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,36--1,37) })], (1,0--1,44))], + PreXmlDocEmpty, [], None, (1,0--1,44), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(1,44) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 06' based on the file name 'ActivePatternAnd 06.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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs new file mode 100644 index 00000000000..1d50cd1a7c2 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs @@ -0,0 +1 @@ +let (_ : exn & (Failure _) | _) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs.bsl new file mode 100644 index 00000000000..71db7cf842c --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 07.fs.bsl @@ -0,0 +1,38 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternAnd 07.fs", false, + QualifiedNameOfFile ActivePatternAnd 07, [], [], + [SynModuleOrNamespace + ([ActivePatternAnd 07], 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)); + 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)), + Wild (1,29--1,30), (1,5--1,30), + { BarRange = (1,27--1,28) }), (1,4--1,31)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (1,38--1,40)), + (1,34--1,40)), (1,4--1,31), Yes (1,0--1,40), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,32--1,33) })], (1,0--1,40))], + PreXmlDocEmpty, [], None, (1,0--1,40), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(1,40) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 07' based on the file name 'ActivePatternAnd 07.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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs new file mode 100644 index 00000000000..220472681c3 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs @@ -0,0 +1 @@ +let ((_ : exn) & Failure _ | (_)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs.bsl new file mode 100644 index 00000000000..c2c958503a8 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternAnd 08.fs.bsl @@ -0,0 +1,38 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternAnd 08.fs", false, + QualifiedNameOfFile ActivePatternAnd 08, [], [], + [SynModuleOrNamespace + ([ActivePatternAnd 08], 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 + ([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)), Paren (Wild (1,30--1,31), (1,29--1,32)), + (1,5--1,32), { BarRange = (1,27--1,28) }), (1,4--1,33)), + None, + App + (NonAtomic, false, Ident exn, Const (Unit, (1,40--1,42)), + (1,36--1,42)), (1,4--1,33), Yes (1,0--1,42), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,34--1,35) })], (1,0--1,42))], + PreXmlDocEmpty, [], None, (1,0--1,42), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(1,42) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternAnd 08' based on the file name 'ActivePatternAnd 08.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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs new file mode 100644 index 00000000000..164868fd113 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs @@ -0,0 +1,3 @@ +exception MyExn + +let (_ : exn & MyExn) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs.bsl new file mode 100644 index 00000000000..f90393a139b --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 01.fs.bsl @@ -0,0 +1,43 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 01.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 01, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 01], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Ands + ([Typed + (Wild (3,5--3,6), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,5--3,12)); + LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,15--3,20))], (3,5--3,20)), + (3,4--3,21)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,28--3,30)), + (3,24--3,30)), (3,4--3,21), Yes (3,0--3,30), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,22--3,23) })], (3,0--3,30))], + PreXmlDocEmpty, [], None, (1,0--3,30), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 01' based on the file name 'ActivePatternExceptionAnd 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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs new file mode 100644 index 00000000000..9cae7fcde59 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs @@ -0,0 +1,3 @@ +exception MyExn + +let ((_ : exn) & MyExn) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs.bsl new file mode 100644 index 00000000000..ad1420869f1 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 02.fs.bsl @@ -0,0 +1,44 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 02.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 02, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 02], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Ands + ([Paren + (Typed + (Wild (3,6--3,7), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,6--3,13)), (3,5--3,14)); + LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,17--3,22))], (3,5--3,22)), + (3,4--3,23)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,30--3,32)), + (3,26--3,32)), (3,4--3,23), Yes (3,0--3,32), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,24--3,25) })], (3,0--3,32))], + PreXmlDocEmpty, [], None, (1,0--3,32), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 02' based on the file name 'ActivePatternExceptionAnd 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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs new file mode 100644 index 00000000000..ff279dd75d8 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs @@ -0,0 +1,3 @@ +exception MyExn + +let (_ : exn & (MyExn)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs.bsl new file mode 100644 index 00000000000..1b4bdf7dfd9 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 03.fs.bsl @@ -0,0 +1,44 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 03.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 03, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 03], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Ands + ([Typed + (Wild (3,5--3,6), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,5--3,12)); + Paren + (LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,16--3,21)), (3,15--3,22))], + (3,5--3,22)), (3,4--3,23)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,30--3,32)), + (3,26--3,32)), (3,4--3,23), Yes (3,0--3,32), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,24--3,25) })], (3,0--3,32))], + PreXmlDocEmpty, [], None, (1,0--3,32), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 03' based on the file name 'ActivePatternExceptionAnd 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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs new file mode 100644 index 00000000000..11d5e3c892b --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs @@ -0,0 +1,3 @@ +exception MyExn + +let ((_ : exn) & (MyExn)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs.bsl new file mode 100644 index 00000000000..ea96f1966b4 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 04.fs.bsl @@ -0,0 +1,45 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 04.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 04, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 04], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Ands + ([Paren + (Typed + (Wild (3,6--3,7), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,6--3,13)), (3,5--3,14)); + Paren + (LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,18--3,23)), (3,17--3,24))], + (3,5--3,24)), (3,4--3,25)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,32--3,34)), + (3,28--3,34)), (3,4--3,25), Yes (3,0--3,34), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,26--3,27) })], (3,0--3,34))], + PreXmlDocEmpty, [], None, (1,0--3,34), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 04' based on the file name 'ActivePatternExceptionAnd 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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs new file mode 100644 index 00000000000..7d33237aa1a --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs @@ -0,0 +1,3 @@ +exception MyExn + +let (_ : exn & MyExn | _) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs.bsl new file mode 100644 index 00000000000..2517eb3918d --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 05.fs.bsl @@ -0,0 +1,45 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 05.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 05, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 05], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Or + (Ands + ([Typed + (Wild (3,5--3,6), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,5--3,12)); + LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,15--3,20))], (3,5--3,20)), + Wild (3,23--3,24), (3,5--3,24), + { BarRange = (3,21--3,22) }), (3,4--3,25)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,32--3,34)), + (3,28--3,34)), (3,4--3,25), Yes (3,0--3,34), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,26--3,27) })], (3,0--3,34))], + PreXmlDocEmpty, [], None, (1,0--3,34), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 05' based on the file name 'ActivePatternExceptionAnd 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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs new file mode 100644 index 00000000000..afc4c16b4d0 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs @@ -0,0 +1,3 @@ +exception MyExn + +let ((_ : exn) & (MyExn) | (_)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs.bsl new file mode 100644 index 00000000000..91e95536c83 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 06.fs.bsl @@ -0,0 +1,48 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 06.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 06, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 06], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Or + (Ands + ([Paren + (Typed + (Wild (3,6--3,7), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,6--3,13)), (3,5--3,14)); + Paren + (LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,18--3,23)), (3,17--3,24))], + (3,5--3,24)), Paren (Wild (3,28--3,29), (3,27--3,30)), + (3,5--3,30), { BarRange = (3,25--3,26) }), (3,4--3,31)), + None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,38--3,40)), + (3,34--3,40)), (3,4--3,31), Yes (3,0--3,40), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,32--3,33) })], (3,0--3,40))], + PreXmlDocEmpty, [], None, (1,0--3,40), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 06' based on the file name 'ActivePatternExceptionAnd 06.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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs new file mode 100644 index 00000000000..ac495a6b843 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs @@ -0,0 +1,3 @@ +exception MyExn + +let (_ : exn & (MyExn) | _) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs.bsl new file mode 100644 index 00000000000..35c7d986cf3 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 07.fs.bsl @@ -0,0 +1,46 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 07.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 07, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 07], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Or + (Ands + ([Typed + (Wild (3,5--3,6), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,5--3,12)); + Paren + (LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,16--3,21)), (3,15--3,22))], + (3,5--3,22)), Wild (3,25--3,26), (3,5--3,26), + { BarRange = (3,23--3,24) }), (3,4--3,27)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,34--3,36)), + (3,30--3,36)), (3,4--3,27), Yes (3,0--3,36), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,28--3,29) })], (3,0--3,36))], + PreXmlDocEmpty, [], None, (1,0--3,36), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 07' based on the file name 'ActivePatternExceptionAnd 07.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. diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs new file mode 100644 index 00000000000..27ae3ae7002 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs @@ -0,0 +1,3 @@ +exception MyExn + +let ((_ : exn) & MyExn | (_)) = exn () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs.bsl new file mode 100644 index 00000000000..d61d4fa3ef0 --- /dev/null +++ b/tests/service/data/SyntaxTree/OperatorName/ActivePatternExceptionAnd 08.fs.bsl @@ -0,0 +1,46 @@ +ImplFile + (ParsedImplFileInput + ("/root/OperatorName/ActivePatternExceptionAnd 08.fs", false, + QualifiedNameOfFile ActivePatternExceptionAnd 08, [], [], + [SynModuleOrNamespace + ([ActivePatternExceptionAnd 08], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (MyExn, None), Fields [], PreXmlDocEmpty, + None, (1,10--1,15), { BarRange = None }), None, + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), None, + (1,0--1,15)), None, [], (1,0--1,15)), (1,0--1,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Paren + (Or + (Ands + ([Paren + (Typed + (Wild (3,6--3,7), + LongIdent (SynLongIdent ([exn], [], [None])), + (3,6--3,13)), (3,5--3,14)); + LongIdent + (SynLongIdent ([MyExn], [], [None]), None, None, + Pats [], None, (3,17--3,22))], (3,5--3,22)), + Paren (Wild (3,26--3,27), (3,25--3,28)), (3,5--3,28), + { BarRange = (3,23--3,24) }), (3,4--3,29)), None, + App + (NonAtomic, false, Ident exn, Const (Unit, (3,36--3,38)), + (3,32--3,38)), (3,4--3,29), Yes (3,0--3,38), + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,30--3,31) })], (3,0--3,38))], + PreXmlDocEmpty, [], None, (1,0--3,38), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'ActivePatternExceptionAnd 08' based on the file name 'ActivePatternExceptionAnd 08.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. From cd6bee89056a980e9f4c23d2cdcdd6f313b9abe3 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 13 May 2024 14:55:28 +0200 Subject: [PATCH 5/5] More tests --- .../.FSharp.Compiler.Service/8.0.400.md | 2 +- .../Language/ConstraintIntersectionTests.fs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md index 11f63225348..63313a5b3c9 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md @@ -12,7 +12,7 @@ * Fix calling an overridden virtual static method via the interface ([PR #17013](https://github.com/dotnet/fsharp/pull/17013)) * Fix state machines compilation, when big decision trees are involved, by removing code split when resumable code is detected ([PR #17076](https://github.com/dotnet/fsharp/pull/17076)) * Fix for exponential runtime in CE builders when using nested implicit yields [PR #17096](https://github.com/dotnet/fsharp/pull/17096) -* Fix several AND operator parser regressions ([Issue #16447](https://github.com/dotnet/fsharp/issues/16447), [Issue #17134](https://github.com/dotnet/fsharp/issues/17134), [PR #17113](https://github.com/dotnet/fsharp/pull/17113)) +* Fix several AND operator parser bugs and regressions ([Issue #16447](https://github.com/dotnet/fsharp/issues/16447), [Issue #17134](https://github.com/dotnet/fsharp/issues/17134), [Issue #16309](https://github.com/dotnet/fsharp/issues/16309), [PR #17113](https://github.com/dotnet/fsharp/pull/17113)) ### Added diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs index 63cc6e18dfa..7a5b9488a60 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs @@ -84,4 +84,18 @@ let y (f: #seq & System.IDisposable) = () |> withDiagnostics [ Error 3572, Line 2, Col 25, Line 2, Col 43, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." Error 3572, Line 4, Col 23, Line 4, Col 41, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." - ] \ No newline at end of file + ] + +// bug 16309 +[] +let ``Constraint intersection handles invalid types``() = + FSharp """ +let f (x: 't when 't :> ABRAKADABRAA & #seq) = () + """ + |> withLangVersion80 + |> typecheck + |> shouldFail + |> withDiagnostics [ + Error 0010, Line 2, Col 40, Line 2, Col 41, "Unexpected symbol # in pattern" + Error 0583, Line 2, Col 7, Line 2, Col 8, "Unmatched '('" + ]