Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ type SynPat =

| ArrayOrList of isArray: bool * elementPats: SynPat list * range: range

| Record of fieldPats: ((LongIdent * Ident) * range * SynPat) list * range: range
| Record of fieldPats: ((LongIdent * Ident) * range option * SynPat) list * range: range

| Null of range: range

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ type SynPat =
| ArrayOrList of isArray: bool * elementPats: SynPat list * range: range

/// A record pattern
| Record of fieldPats: ((LongIdent * Ident) * range * SynPat) list * range: range
| Record of fieldPats: ((LongIdent * Ident) * range option * SynPat) list * range: range

/// The 'null' pattern
| Null of range: range
Expand Down
30 changes: 21 additions & 9 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -3591,8 +3591,10 @@ atomicPattern:
{ SynPat.QuoteExpr($1, lhs parseState) }

| LBRACE recordPatternElementsAux rbrace
{ let rs, m = $2
SynPat.Record(rs, rhs2 parseState 1 3) }
{ SynPat.Record($2, rhs2 parseState 1 3) }

| LBRACE error rbrace
{ SynPat.Record([], rhs2 parseState 1 3) }

| LBRACK listPatternElements RBRACK
{ SynPat.ArrayOrList(false, $2, lhs parseState) }
Expand Down Expand Up @@ -3775,19 +3777,29 @@ conjParenPatternElements:
| parenPattern AMP parenPattern
{ $3 :: $1 :: [] }

recordPatternElementsAux: /* Fix 1190 */
recordPatternElementsAux:
| recordPatternElement opt_seps
{ [$1], lhs parseState }
{ [$1] }

| recordPatternElement seps recordPatternElementsAux
{ let r = $1
let (rs, dropMark) = $3
(r :: rs), lhs parseState }
{ $1 :: $3 }

recordPatternElement:
| path EQUALS parenPattern
{ let mEquals = rhs parseState 2
(List.frontAndBack $1.LongIdent, mEquals, $3) }
{ let mPath = $1.Range
let mEquals = rhs parseState 2
let mPat = $3.Range
List.frontAndBack $1.LongIdent, Some mEquals, $3 }

| path EQUALS recover
{ let mPath = $1.Range
let mEquals = rhs parseState 2
let pat = SynPat.Wild(mEquals.EndRange)
List.frontAndBack $1.LongIdent, Some mEquals, pat }

| path recover
{ let pat = SynPat.Wild($1.Range.EndRange)
List.frontAndBack $1.LongIdent, None, pat }

listPatternElements:
| /* EMPTY */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8106,8 +8106,8 @@ FSharp.Compiler.Syntax.SynPat+QuoteExpr: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynPat+QuoteExpr: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynPat+Record: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynPat+Record: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] fieldPats
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] get_fieldPats()
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] fieldPats
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] get_fieldPats()
FSharp.Compiler.Syntax.SynPat+Tags: Int32 Ands
FSharp.Compiler.Syntax.SynPat+Tags: Int32 ArrayOrList
FSharp.Compiler.Syntax.SynPat+Tags: Int32 As
Expand Down Expand Up @@ -8200,7 +8200,7 @@ FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewOptionalVal(FSha
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewOr(FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewParen(FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewQuoteExpr(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewRecord(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewRecord(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewTuple(Boolean, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewTyped(FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewWild(FSharp.Compiler.Text.Range)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8106,8 +8106,8 @@ FSharp.Compiler.Syntax.SynPat+QuoteExpr: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynPat+QuoteExpr: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynPat+Record: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynPat+Record: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] fieldPats
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] get_fieldPats()
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] fieldPats
FSharp.Compiler.Syntax.SynPat+Record: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] get_fieldPats()
FSharp.Compiler.Syntax.SynPat+Tags: Int32 Ands
FSharp.Compiler.Syntax.SynPat+Tags: Int32 ArrayOrList
FSharp.Compiler.Syntax.SynPat+Tags: Int32 As
Expand Down Expand Up @@ -8200,7 +8200,7 @@ FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewOptionalVal(FSha
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewOr(FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewParen(FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewQuoteExpr(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewRecord(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewRecord(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewTuple(Boolean, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewTyped(FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Syntax.SynPat NewWild(FSharp.Compiler.Text.Range)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ImplFile
(NoneAtInvisible, Ident _arg2,
[SynMatchClause
(Record
([(([], Y), (3,9--3,10),
([(([], Y), Some (3,9--3,10),
ListCons
(Named
(SynIdent (h, None), false, None,
Expand Down Expand Up @@ -88,7 +88,7 @@ ImplFile
(2,4--2,10));
Paren
(Record
([(([], Y), (3,9--3,10),
([(([], Y), Some (3,9--3,10),
ListCons
(Named
(SynIdent (h, None), false, None, (3,11--3,12)),
Expand All @@ -108,7 +108,7 @@ ImplFile
(NoneAtInvisible, Ident _arg2,
[SynMatchClause
(Record
([(([], Y), (3,9--3,10),
([(([], Y), Some (3,9--3,10),
ListCons
(Named
(SynIdent (h, None), false, None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ImplFile
(NoneAtInvisible, Ident _arg1,
[SynMatchClause
(Record
([(([], X), (2,8--2,9),
([(([], X), Some (2,8--2,9),
Named
(SynIdent (x, None), false, None, (2,10--2,11)))],
(2,4--2,13)), None,
Expand All @@ -35,14 +35,14 @@ ImplFile
WithKeyword = (2,4--2,22) }),
Some
([Record
([(([], X), (2,8--2,9),
([(([], X), Some (2,8--2,9),
Named (SynIdent (x, None), false, None, (2,10--2,11)))],
(2,4--2,13))],
Match
(NoneAtInvisible, Ident _arg1,
[SynMatchClause
(Record
([(([], X), (2,8--2,9),
([(([], X), Some (2,8--2,9),
Named
(SynIdent (x, None), false, None, (2,10--2,11)))],
(2,4--2,13)), None,
Expand Down
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 01.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

match () with
| { A = _ } -> ()
20 changes: 20 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 01.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ImplFile
(ParsedImplFileInput
("/root/Pattern/Record 01.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Match
(Yes (3,0--3,13), Const (Unit, (3,6--3,8)),
[SynMatchClause
(Record
([(([], A), Some (4,6--4,7), Wild (4,8--4,9))],
(4,2--4,11)), None, Const (Unit, (4,15--4,17)),
(4,2--4,17), Yes, { ArrowRange = Some (4,12--4,14)
BarRange = Some (4,0--4,1) })],
(3,0--4,17), { MatchKeyword = (3,0--3,5)
WithKeyword = (3,9--3,13) }), (3,0--4,17))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,17), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 02.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

match () with
| { A = _; B = _ } -> ()
21 changes: 21 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 02.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ImplFile
(ParsedImplFileInput
("/root/Pattern/Record 02.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Match
(Yes (3,0--3,13), Const (Unit, (3,6--3,8)),
[SynMatchClause
(Record
([(([], A), Some (4,6--4,7), Wild (4,8--4,9));
(([], B), Some (4,13--4,14), Wild (4,15--4,16))],
(4,2--4,18)), None, Const (Unit, (4,22--4,24)),
(4,2--4,24), Yes, { ArrowRange = Some (4,19--4,21)
BarRange = Some (4,0--4,1) })],
(3,0--4,24), { MatchKeyword = (3,0--3,5)
WithKeyword = (3,9--3,13) }), (3,0--4,24))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,24), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 03.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

match () with
| { A = } -> ()
22 changes: 22 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 03.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ImplFile
(ParsedImplFileInput
("/root/Pattern/Record 03.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Match
(Yes (3,0--3,13), Const (Unit, (3,6--3,8)),
[SynMatchClause
(Record
([(([], A), Some (4,6--4,7), Wild (4,7--4,7))],
(4,2--4,9)), None, Const (Unit, (4,13--4,15)),
(4,2--4,15), Yes, { ArrowRange = Some (4,10--4,12)
BarRange = Some (4,0--4,1) })],
(3,0--4,15), { MatchKeyword = (3,0--3,5)
WithKeyword = (3,9--3,13) }), (3,0--4,15))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,15), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,8)-(4,9) parse error Unexpected symbol '}' in pattern
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 04.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

match () with
| { A } -> ()
21 changes: 21 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 04.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ImplFile
(ParsedImplFileInput
("/root/Pattern/Record 04.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Match
(Yes (3,0--3,13), Const (Unit, (3,6--3,8)),
[SynMatchClause
(Record ([(([], A), None, Wild (4,5--4,5))], (4,2--4,7)),
None, Const (Unit, (4,11--4,13)), (4,2--4,13), Yes,
{ ArrowRange = Some (4,8--4,10)
BarRange = Some (4,0--4,1) })], (3,0--4,13),
{ MatchKeyword = (3,0--3,5)
WithKeyword = (3,9--3,13) }), (3,0--4,13))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,6)-(4,7) parse error Unexpected symbol '}' in pattern. Expected '.', '=' or other token.
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 05.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

match () with
| { } -> ()
20 changes: 20 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 05.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ImplFile
(ParsedImplFileInput
("/root/Pattern/Record 05.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Match
(Yes (3,0--3,13), Const (Unit, (3,6--3,8)),
[SynMatchClause
(Record ([], (4,2--4,5)), None, Const (Unit, (4,9--4,11)),
(4,2--4,11), Yes, { ArrowRange = Some (4,6--4,8)
BarRange = Some (4,0--4,1) })],
(3,0--4,11), { MatchKeyword = (3,0--3,5)
WithKeyword = (3,9--3,13) }), (3,0--4,11))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,11), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,4)-(4,5) parse error Unexpected symbol '}' in pattern. Expected identifier, 'global' or other token.
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 06.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

match () with
| { _ } -> ()
20 changes: 20 additions & 0 deletions tests/service/data/SyntaxTree/Pattern/Record 06.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ImplFile
(ParsedImplFileInput
("/root/Pattern/Record 06.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Match
(Yes (3,0--3,13), Const (Unit, (3,6--3,8)),
[SynMatchClause
(Record ([], (4,2--4,7)), None, Const (Unit, (4,11--4,13)),
(4,2--4,13), Yes, { ArrowRange = Some (4,8--4,10)
BarRange = Some (4,0--4,1) })],
(3,0--4,13), { MatchKeyword = (3,0--3,5)
WithKeyword = (3,9--3,13) }), (3,0--4,13))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,4)-(4,5) parse error Unexpected symbol '_' in pattern. Expected identifier, 'global' or other token.

This file was deleted.

This file was deleted.