Skip to content

Commit

Permalink
Fix recovery of member _ (#15540)
Browse files Browse the repository at this point in the history
* Fix recovery of member with wildcard this

* Update CheckExpressions.fs

* Refactor
  • Loading branch information
kerams authored Jul 18, 2023
1 parent c271484 commit 09143a5
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ module MutRecBindingChecking =
let innerState = (incrClassCtorLhsOpt, envForTycon, tpenv, recBindIdx, uncheckedBindsRev)
[Phase2AIncrClassBindings (tcref, letBinds, isStatic, isRec, m)], innerState

| SynMemberDefn.Member(SynBinding(headPat = SynPat.Wild _; expr = SynExpr.ArbitraryAfterError _), _), _
| SynMemberDefn.Member(SynBinding(headPat = SynPat.FromParseError(SynPat.Wild _, _)), _), _ ->
[], innerState

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3930,7 +3930,7 @@ let GetInstanceMemberThisVariable (vspec: Val, expr) =
// Skip over LAM tps. Choose 'a.
if vspec.IsInstanceMember then
let rec firstArg e =
match stripDebugPoints e with
match stripDebugPoints e with
| Expr.TyLambda (_, _, b, _, _) -> firstArg b
| Expr.TyChoose (_, b, _) -> firstArg b
| Expr.Lambda (_, _, _, [v], _, _, _) -> Some v
Expand Down
6 changes: 6 additions & 0 deletions tests/service/data/SyntaxTree/Member/Member 10.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Module

type U =
| A

member _
48 changes: 48 additions & 0 deletions tests/service/data/SyntaxTree/Member/Member 10.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
ImplFile
(ParsedImplFileInput
("/root/Member/Member 10.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [U],
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (3,5--3,6)),
Simple
(Union
(None,
[SynUnionCase
([], SynIdent (A, None), Fields [],
PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector),
None, (4,6--4,7), { BarRange = Some (4,4--4,5) })],
(4,4--4,7)), (4,4--4,7)),
[Member
(SynBinding
(None, Normal, false, false, [],
PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector),
SynValData
(Some { IsInstance = true
IsDispatchSlot = false
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
MemberKind = Member },
SynValInfo
([[SynArgInfo ([], false, None)]; []],
SynArgInfo ([], false, None)), None),
Wild (6,11--6,12), None,
ArbitraryAfterError ("memberCore2", (6,12--6,12)),
(6,11--6,12), NoneAtInvisible,
{ LeadingKeyword = Member (6,4--6,10)
InlineKeyword = None
EqualsRange = None }), (6,4--6,12))], None,
(3,5--6,12), { LeadingKeyword = Type (3,0--3,4)
EqualsRange = Some (3,7--3,8)
WithKeyword = None })], (3,0--6,12))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--6,12), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(7,0)-(7,0) parse error Incomplete structured construct at or before this point in member definition. Expected 'with', '=' or other token.
6 changes: 6 additions & 0 deletions tests/service/data/SyntaxTree/Member/Member 11.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Module

type U =
| A

member _.
48 changes: 48 additions & 0 deletions tests/service/data/SyntaxTree/Member/Member 11.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
ImplFile
(ParsedImplFileInput
("/root/Member/Member 11.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [U],
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (3,5--3,6)),
Simple
(Union
(None,
[SynUnionCase
([], SynIdent (A, None), Fields [],
PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector),
None, (4,6--4,7), { BarRange = Some (4,4--4,5) })],
(4,4--4,7)), (4,4--4,7)),
[Member
(SynBinding
(None, Normal, false, false, [],
PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector),
SynValData
(Some { IsInstance = true
IsDispatchSlot = false
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
MemberKind = Member },
SynValInfo
([[SynArgInfo ([], false, None)]; []],
SynArgInfo ([], false, None)), None),
FromParseError (Wild (6,10--6,10), (6,10--6,10)), None,
ArbitraryAfterError ("classDefnMember1", (6,10--6,10)),
(6,4--6,10), NoneAtInvisible,
{ LeadingKeyword = Member (6,4--6,10)
InlineKeyword = None
EqualsRange = None }), (6,4--6,10))], None,
(3,5--6,10), { LeadingKeyword = Type (3,0--3,4)
EqualsRange = Some (3,7--3,8)
WithKeyword = None })], (3,0--6,10))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--6,10), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(7,0)-(7,0) parse error Incomplete structured construct at or before this point in member definition. Expected identifier, '(', '(*)' or other token.

0 comments on commit 09143a5

Please sign in to comment.