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
117 changes: 81 additions & 36 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,11 @@ simplePattern:
| simplePattern COLON typeWithTypeConstraints
{ SynPat.Typed($1, $3, lhs parseState) }

| simplePattern COLON recover
{ let mColon = rhs parseState 2
let ty = SynType.FromParseError(mColon.EndRange)
SynPat.Typed($1, ty, unionRanges $1.Range mColon) }

| attributes simplePattern %prec paren_pat_attribs
{ SynPat.Attrib($2, $1, lhs parseState) }

Expand Down Expand Up @@ -3341,9 +3346,14 @@ parenPattern:
| conjParenPatternElements
{ SynPat.Ands(List.rev $1, rhs2 parseState 1 3) }

| parenPattern COLON typeWithTypeConstraints %prec paren_pat_colon
{ let mLhs = lhs parseState
SynPat.Typed($1, $3, mLhs) }
| parenPattern COLON typeWithTypeConstraints %prec paren_pat_colon
{ let mLhs = lhs parseState
SynPat.Typed($1, $3, mLhs) }

| parenPattern COLON recover
{ let mColon = rhs parseState 2
let ty = SynType.FromParseError(mColon.EndRange)
SynPat.Typed($1, ty, unionRanges $1.Range mColon) }

| attributes parenPattern %prec paren_pat_attribs
{ let mLhs = lhs parseState
Expand Down Expand Up @@ -5094,15 +5104,20 @@ topTypeWithTypeConstraints:
// nb. it doesn't matter where the constraints go in the structure of the type.
SynType.WithGlobalConstraints(ty, List.rev $3, lhs parseState), arity }

opt_topReturnTypeWithTypeConstraints:
|
{ None }
opt_topReturnTypeWithTypeConstraints:
|
{ None }

| COLON topTypeWithTypeConstraints
{ let mColon = rhs parseState 1
let ty, arity = $2
let arity = (match arity with SynValInfo([], rmdata)-> rmdata | _ -> SynInfo.unnamedRetVal)
Some (Some mColon, SynReturnInfo((ty, arity), rhs parseState 2)) }

| COLON topTypeWithTypeConstraints
{ let mColon = rhs parseState 1
let ty, arity = $2
let arity = (match arity with SynValInfo([], rmdata)-> rmdata | _ -> SynInfo.unnamedRetVal)
Some (Some mColon, SynReturnInfo((ty, arity), rhs parseState 2)) }
| COLON recover
{ let mColon = rhs parseState 1
let ty, arity = SynType.FromParseError(mColon.EndRange), SynInfo.unnamedRetVal
Some (Some mColon, SynReturnInfo((ty, arity), mColon.EndRange)) }

topType:
| topTupleType RARROW topType
Expand Down Expand Up @@ -5136,31 +5151,61 @@ topTupleTypeElements:
[ SynTupleTypeSegment.Type t, Some argInfo ] }

topAppType:
| attributes appType COLON appType
{ match $2 with
| SynType.LongIdent(SynLongIdent([id], _, _)) ->
let m = rhs2 parseState 1 4
SynType.SignatureParameter($1, false, Some id, $4, m), SynArgInfo($1, false, Some id)
| _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }

| attributes QMARK ident COLON appType
{ let m = rhs2 parseState 1 5
SynType.SignatureParameter($1, true, Some $3, $5, m), SynArgInfo($1, true, Some $3) }

| attributes appType
{ let m = rhs2 parseState 1 2
SynType.SignatureParameter($1, false, None, $2, m), SynArgInfo($1, false, None) }

| appType COLON appType
{ match $1 with
| SynType.LongIdent(SynLongIdent([id], _, _)) ->
let m = rhs2 parseState 1 3
SynType.SignatureParameter([], false, Some id, $3, m), SynArgInfo([], false, Some id)
| _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }

| QMARK ident COLON appType
{ let m = rhs2 parseState 1 4
SynType.SignatureParameter([], true, Some $2, $4, m), SynArgInfo([], true, Some $2) }
| attributes appType COLON appType
{ match $2 with
| SynType.LongIdent(SynLongIdent([id], _, _)) ->
let m = unionRanges (rhs parseState 1) $4.Range
SynType.SignatureParameter($1, false, Some id, $4, m), SynArgInfo($1, false, Some id)
| _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }

| attributes appType COLON recover
{ match $2 with
| SynType.LongIdent(SynLongIdent([id], _, _)) ->
let mColon = rhs parseState 2
let m = unionRanges (rhs parseState 1) mColon
let ty = SynType.FromParseError(mColon.EndRange)
SynType.SignatureParameter($1, false, Some id, ty, m), SynArgInfo($1, false, Some id)
| _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }

| attributes QMARK ident COLON appType
{ let m = unionRanges (rhs parseState 1) $5.Range
SynType.SignatureParameter($1, true, Some $3, $5, m), SynArgInfo($1, true, Some $3) }

| attributes QMARK ident COLON recover
{ let mColon = rhs parseState 4
let m = unionRanges (rhs parseState 1) mColon
let ty = SynType.FromParseError(mColon.EndRange)
SynType.SignatureParameter($1, true, Some $3, ty, m), SynArgInfo($1, true, Some $3) }

| attributes appType
{ let m = unionRanges (rhs parseState 1) $2.Range
SynType.SignatureParameter($1, false, None, $2, m), SynArgInfo($1, false, None) }

| appType COLON appType
{ match $1 with
| SynType.LongIdent(SynLongIdent([id], _, _)) ->
let m = unionRanges (rhs parseState 1) $3.Range
SynType.SignatureParameter([], false, Some id, $3, m), SynArgInfo([], false, Some id)
| _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }

| appType COLON recover
{ match $1 with
| SynType.LongIdent(SynLongIdent([id], _, _)) ->
let mColon = rhs parseState 2
let m = unionRanges $1.Range mColon
let ty = SynType.FromParseError(mColon.EndRange)
SynType.SignatureParameter([], false, Some id, ty, m), SynArgInfo([], false, Some id)
| _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }

| QMARK ident COLON appType
{ let m = unionRanges (rhs parseState 1) $4.Range
SynType.SignatureParameter([], true, Some $2, $4, m), SynArgInfo([], true, Some $2) }

| QMARK ident COLON recover
{ let mColon = rhs parseState 3
let m = unionRanges (rhs parseState 1) mColon
let ty = SynType.FromParseError(mColon.EndRange)
SynType.SignatureParameter([], true, Some $2, ty, m), SynArgInfo([], true, Some $2) }

| appType
{ $1, SynArgInfo([], false, None) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// #Regression #Diagnostics
// Regression test for DevDiv:64339
// Note that the bug still repros in CHK/DBG bits - we will knownfail it
//<Expects status="error" span="(10,25-10,29)" id="FS0010">Unexpected keyword 'lazy' in type definition$</Expects>
//<Expects status="error" span="(10,8-10,9)" id="FS0583">Unmatched '\('$</Expects>
//<Expects status="error" span="(13,29-13,33)" id="FS0010">Unexpected keyword 'lazy'$</Expects>
//<Expects status="error" span="(13,9-13,10)" id="FS0583">Unmatched '\('$</Expects>
//<Expects status="error" span="(8,25-8,29)" id="FS0010">Unexpected keyword 'lazy' in type definition$</Expects>
//<Expects status="error" span="(11,29-11,33)" id="FS0010">Unexpected keyword 'lazy'$</Expects>

// 5 elements -> ok
type Ok(a, b, c, d, e : lazy<int>) = class end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

(fun i:)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ImplFile
(ParsedImplFileInput
("/root/Lambda/Param - Missing type 01.fs", false,
QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Paren
(FromParseError
(Lambda
(false, false,
SimplePats
([Id (i, None, false, false, false, (3,5--3,6))],
(3,5--3,6)),
ArbitraryAfterError ("anonLambdaExpr4", (3,6--3,6)),
Some
([Named (SynIdent (i, None), false, None, (3,5--3,6))],
ArbitraryAfterError ("anonLambdaExpr4", (3,6--3,6))),
(3,1--3,6), { ArrowRange = None }), (3,1--3,6)),
(3,0--3,1), Some (3,7--3,8), (3,0--3,8)), (3,0--3,8))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,8), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,6)-(3,7) parse error Unexpected symbol ':' in lambda expression. Expected '->' or other token.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

(fun i: -> ())
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ImplFile
(ParsedImplFileInput
("/root/Lambda/Param - Missing type 02.fs", false,
QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Paren
(FromParseError
(Lambda
(false, false,
SimplePats
([Id (i, None, false, false, false, (3,5--3,6))],
(3,5--3,6)),
ArbitraryAfterError ("anonLambdaExpr4", (3,6--3,6)),
Some
([Named (SynIdent (i, None), false, None, (3,5--3,6))],
ArbitraryAfterError ("anonLambdaExpr4", (3,6--3,6))),
(3,1--3,6), { ArrowRange = None }), (3,1--3,6)),
(3,0--3,1), Some (3,13--3,14), (3,0--3,14)), (3,0--3,14))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,14), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,6)-(3,7) parse error Unexpected symbol ':' in lambda expression. Expected '->' or other token.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

(fun (i:) -> ())
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ImplFile
(ParsedImplFileInput
("/root/Lambda/Param - Missing type 03.fs", false,
QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Paren
(Lambda
(false, false,
SimplePats
([Typed
(Id (i, None, false, false, false, (3,6--3,7)),
FromParseError (3,8--3,8), (3,6--3,8))], (3,5--3,9)),
Const (Unit, (3,13--3,15)),
Some
([Paren
(Typed
(Named
(SynIdent (i, None), false, None, (3,6--3,7)),
FromParseError (3,8--3,8), (3,6--3,8)), (3,5--3,9))],
Const (Unit, (3,13--3,15))), (3,1--3,15),
{ ArrowRange = Some (3,10--3,12) }), (3,0--3,1),
Some (3,15--3,16), (3,0--3,16)), (3,0--3,16))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,16), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,8)-(3,9) parse error Unexpected symbol ')' in pattern
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

(fun (i:, j) -> ())
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ImplFile
(ParsedImplFileInput
("/root/Lambda/Param - Missing type 04.fs", false,
QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Paren
(Lambda
(false, false,
SimplePats
([Typed
(Id (i, None, false, false, false, (3,6--3,7)),
FromParseError (3,8--3,8), (3,6--3,8));
Id (j, None, false, false, false, (3,10--3,11))],
(3,5--3,12)), Const (Unit, (3,16--3,18)),
Some
([Paren
(Tuple
(false,
[Typed
(Named
(SynIdent (i, None), false, None, (3,6--3,7)),
FromParseError (3,8--3,8), (3,6--3,8));
Named
(SynIdent (j, None), false, None, (3,10--3,11))],
(3,6--3,11)), (3,5--3,12))],
Const (Unit, (3,16--3,18))), (3,1--3,18),
{ ArrowRange = Some (3,13--3,15) }), (3,0--3,1),
Some (3,18--3,19), (3,0--3,19)), (3,0--3,19))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,19), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,8)-(3,9) parse error Unexpected symbol ',' in pattern
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

type T(i:) = class end
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ImplFile
(ParsedImplFileInput
("/root/Member/Implicit ctor - Missing type 01.fs", false,
QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [T],
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (3,5--3,6)),
ObjectModel
(Class,
[ImplicitCtor
(None, [],
SimplePats
([Typed
(Id (i, None, false, false, false, (3,7--3,8)),
FromParseError (3,9--3,9), (3,7--3,9))],
(3,6--3,10)), None,
PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector),
(3,5--3,6), { AsKeyword = None })], (3,13--3,22)), [],
Some
(ImplicitCtor
(None, [],
SimplePats
([Typed
(Id (i, None, false, false, false, (3,7--3,8)),
FromParseError (3,9--3,9), (3,7--3,9))],
(3,6--3,10)), None,
PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector),
(3,5--3,6), { AsKeyword = None })), (3,5--3,22),
{ LeadingKeyword = Type (3,0--3,4)
EqualsRange = Some (3,11--3,12)
WithKeyword = None })], (3,0--3,22))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,22), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,9)-(3,10) parse error Unexpected symbol ')' in type definition
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

type T(i:, j) = class end
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ImplFile
(ParsedImplFileInput
("/root/Member/Implicit ctor - Missing type 02.fs", false,
QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [T],
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (3,5--3,6)),
ObjectModel
(Class,
[ImplicitCtor
(None, [],
SimplePats
([Typed
(Id (i, None, false, false, false, (3,7--3,8)),
FromParseError (3,9--3,9), (3,7--3,9));
Id (j, None, false, false, false, (3,11--3,12))],
(3,6--3,13)), None,
PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector),
(3,5--3,6), { AsKeyword = None })], (3,16--3,25)), [],
Some
(ImplicitCtor
(None, [],
SimplePats
([Typed
(Id (i, None, false, false, false, (3,7--3,8)),
FromParseError (3,9--3,9), (3,7--3,9));
Id (j, None, false, false, false, (3,11--3,12))],
(3,6--3,13)), None,
PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector),
(3,5--3,6), { AsKeyword = None })), (3,5--3,25),
{ LeadingKeyword = Type (3,0--3,4)
EqualsRange = Some (3,14--3,15)
WithKeyword = None })], (3,0--3,25))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,25), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,9)-(3,10) parse error Unexpected symbol ',' in type definition
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

type T =
member this.M(i:) = ()
Loading