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
28 changes: 24 additions & 4 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -3458,9 +3458,14 @@ typedSequentialExprBlockR:
| recover
{ fun mStart -> arbExpr ("typedSequentialExprBlockR", mStart) }

typedSequentialExpr:
typedSequentialExpr:
| sequentialExpr COLON typeWithTypeConstraints
{ SynExpr.Typed ($1, $3, unionRanges $1.Range $3.Range) }
{ SynExpr.Typed ($1, $3, unionRanges $1.Range $3.Range) }

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

| sequentialExpr
{ $1 }
Expand Down Expand Up @@ -3889,14 +3894,29 @@ declExpr:
SynExpr.YieldOrReturn ((true, true), expr, (unionRanges mArrow expr.Range)) }

| declExpr COLON_QMARK typ
{ SynExpr.TypeTest ($1, $3, unionRanges $1.Range $3.Range) }
{ SynExpr.TypeTest($1, $3, unionRanges $1.Range $3.Range) }

| declExpr COLON_QMARK recover
{ let mColon = rhs parseState 2
let ty = SynType.FromParseError(mColon.EndRange)
SynExpr.TypeTest($1, ty, unionRanges $1.Range mColon) }

| declExpr COLON_GREATER typ
{ SynExpr.Upcast ($1, $3, unionRanges $1.Range $3.Range) }
{ SynExpr.Upcast($1, $3, unionRanges $1.Range $3.Range) }

| declExpr COLON_GREATER recover
{ let mOp = rhs parseState 2
let ty = SynType.FromParseError(mOp.EndRange)
SynExpr.Upcast($1, ty, unionRanges $1.Range mOp) }

| declExpr COLON_QMARK_GREATER typ
{ SynExpr.Downcast ($1, $3, unionRanges $1.Range $3.Range) }

| declExpr COLON_QMARK_GREATER recover
{ let mOp = rhs parseState 2
let ty = SynType.FromParseError(mOp.EndRange)
SynExpr.Downcast($1, ty, unionRanges $1.Range mOp) }

| declExpr COLON_EQUALS declExpr
{ mkSynInfix (rhs parseState 2) $1 ":=" $3 }

Expand Down
3 changes: 3 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Downcast 01.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

i :?>
16 changes: 16 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Downcast 01.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Downcast 01.fs", false, QualifiedNameOfFile Module, [],
[],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Downcast (Ident i, FromParseError (3,5--3,5), (3,0--3,5)),
(3,0--3,5))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,5), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,0)-(4,0) parse warning Possible incorrect indentation: this token is offside of context started at position (3:1). Try indenting this token further or using standard formatting conventions.
(4,0)-(4,0) parse error Incomplete structured construct at or before this point in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Downcast 02.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i :?>
()
13 changes: 13 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Downcast 02.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Downcast 02.fs", false, QualifiedNameOfFile Module, [],
[],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr (Downcast (Ident i, Anon (4,0--4,2), (3,0--4,2)), (3,0--4,2))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,2), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,1)-(4,2) parse error Unexpected symbol ')' in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Downcast 03.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i :?>
i
14 changes: 14 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Downcast 03.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Downcast 03.fs", false, QualifiedNameOfFile Module, [],
[],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Downcast
(Ident i, LongIdent (SynLongIdent ([i], [], [None])), (3,0--4,1)),
(3,0--4,1))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
3 changes: 3 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 01.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

i :?
15 changes: 15 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 01.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Type test 01.fs", false, QualifiedNameOfFile Module, [],
[],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(TypeTest (Ident i, FromParseError (3,4--3,4), (3,0--3,4)),
(3,0--3,4))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,4), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,0)-(4,0) parse error Incomplete structured construct at or before this point in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 02.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i :?
()
15 changes: 15 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 02.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Type test 02.fs", false, QualifiedNameOfFile Module, [],
[],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(TypeTest (Ident i, FromParseError (3,4--3,4), (3,0--3,4)),
(3,0--3,4)); Expr (Const (Unit, (4,0--4,2)), (4,0--4,2))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,2), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,5)-(4,0) parse error Incomplete structured construct at or before this point in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 03.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i :?
i
15 changes: 15 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 03.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Type test 03.fs", false, QualifiedNameOfFile Module, [],
[],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(TypeTest (Ident i, FromParseError (3,4--3,4), (3,0--3,4)),
(3,0--3,4)); Expr (Ident i, (4,0--4,1))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,5)-(4,0) parse error Incomplete structured construct at or before this point in expression
3 changes: 3 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 04.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

if i :? then ()
21 changes: 21 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Type test 04.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Type test 04.fs", false, QualifiedNameOfFile Module, [],
[],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(IfThenElse
(TypeTest (Ident i, FromParseError (3,7--3,7), (3,3--3,7)),
Const (Unit, (3,13--3,15)), None, Yes (3,0--3,12), false,
(3,0--3,15), { IfKeyword = (3,0--3,2)
IsElif = false
ThenKeyword = (3,8--3,12)
ElseKeyword = None
IfToThenRange = (3,0--3,12) }), (3,0--3,15))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,15), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,8)-(3,12) parse error Unexpected keyword 'then' in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 01.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i:
()
11 changes: 11 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 01.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Typed 01.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule, [Expr (Ident i, (3,0--3,1))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,1)-(3,2) parse error Unexpected symbol ':' in definition. Expected incomplete structured construct at or before this point or other token.
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 02.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i:
i
11 changes: 11 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 02.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Typed 02.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule, [Expr (Ident i, (3,0--3,1))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(3,1)-(3,2) parse error Unexpected symbol ':' in definition. Expected incomplete structured construct at or before this point or other token.
5 changes: 5 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 03.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Module

do
i:
i
15 changes: 15 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 03.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Typed 03.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Do
(Typed (Ident i, FromParseError (4,6--4,6), (4,4--4,6)),
(3,0--4,6)), (3,0--4,6)); Expr (Ident i, (5,0--5,1))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--5,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(5,0)-(5,1) parse error Incomplete structured construct at or before this point in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 04.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

do
i:
15 changes: 15 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Typed 04.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Typed 04.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Do
(Typed (Ident i, FromParseError (4,6--4,6), (4,4--4,6)),
(3,0--4,6)), (3,0--4,6))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,6), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(5,0)-(5,0) parse error Incomplete structured construct at or before this point in expression
3 changes: 3 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 01.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Module

i :>
15 changes: 15 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 01.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Upcast 01.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Upcast (Ident i, FromParseError (3,4--3,4), (3,0--3,4)),
(3,0--3,4))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--3,4), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,0)-(4,0) parse warning Possible incorrect indentation: this token is offside of context started at position (3:1). Try indenting this token further or using standard formatting conventions.
(4,0)-(4,0) parse error Incomplete structured construct at or before this point in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 02.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i :>
()
12 changes: 12 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 02.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Upcast 02.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr (Upcast (Ident i, Anon (4,0--4,2), (3,0--4,2)), (3,0--4,2))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,2), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(4,1)-(4,2) parse error Unexpected symbol ')' in expression
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 03.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

i :>
i
13 changes: 13 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 03.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Upcast 03.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Upcast
(Ident i, LongIdent (SynLongIdent ([i], [], [None])), (3,0--4,1)),
(3,0--4,1))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--4,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
5 changes: 5 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 04.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Module

do
i :>
()
16 changes: 16 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 04.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Upcast 04.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Do (Upcast (Ident i, Anon (5,0--5,2), (4,4--5,2)), (3,0--5,2)),
(3,0--5,2))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--5,2), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(5,0)-(5,1) parse warning Possible incorrect indentation: this token is offside of context started at position (4:5). Try indenting this token further or using standard formatting conventions.
(5,0)-(5,1) parse warning Possible incorrect indentation: this token is offside of context started at position (4:5). Try indenting this token further or using standard formatting conventions.
(5,1)-(5,2) parse error Unexpected symbol ')' in expression
5 changes: 5 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 05.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Module

do
i :>
i
17 changes: 17 additions & 0 deletions tests/service/data/SyntaxTree/Expression/Upcast 05.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ImplFile
(ParsedImplFileInput
("/root/Expression/Upcast 05.fs", false, QualifiedNameOfFile Module, [], [],
[SynModuleOrNamespace
([Module], false, NamedModule,
[Expr
(Do
(Upcast
(Ident i, LongIdent (SynLongIdent ([i], [], [None])),
(4,4--5,1)), (3,0--5,1)), (3,0--5,1))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--5,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(5,0)-(5,1) parse warning Possible incorrect indentation: this token is offside of context started at position (4:5). Try indenting this token further or using standard formatting conventions.
(5,0)-(5,1) parse warning Possible incorrect indentation: this token is offside of context started at position (4:5). Try indenting this token further or using standard formatting conventions.