Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5e92ead
allow dropping yield in sequence expressions
dsyme Mar 2, 2019
177c5ef
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme Mar 3, 2019
0794413
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme Mar 9, 2019
339bbcc
update tests
dsyme Mar 9, 2019
8cdfe06
update xlf
dsyme Mar 10, 2019
3b98c68
fix test
dsyme Mar 10, 2019
b9b5881
update baseline
dsyme Mar 11, 2019
54a93a5
implicit yield for computation expressions
dsyme Mar 11, 2019
e4e97c9
Merge branch 'diag4' into seq4
dsyme Mar 11, 2019
77e03e7
Merge branch 'diag4' into seq4
dsyme Mar 11, 2019
721e416
Merge branch 'diag4' into seq4
dsyme Mar 11, 2019
826f499
Merge branch 'diag4' into seq4
dsyme Mar 11, 2019
aee22b9
fix tests, merge diag4
dsyme Mar 11, 2019
170ea88
merge master
dsyme Mar 11, 2019
4bbd54f
fix test
dsyme Mar 11, 2019
5a39c70
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme Mar 12, 2019
a343159
update tests
dsyme Mar 12, 2019
d937f80
fix tests
dsyme Mar 12, 2019
94b70d2
fix test
dsyme Mar 12, 2019
764c290
Merge branch 'master' into seq4
dsyme Mar 19, 2019
c5f0d2a
integrate master
dsyme Mar 20, 2019
47b3137
Merge branch 'seq4' of https://github.com/dsyme/visualfsharp into seq4
dsyme Mar 20, 2019
e7a0c93
Merge branch 'master' of https://github.com/Microsoft/visualfsharp in…
dsyme Mar 21, 2019
4642f4b
merge master
dsyme Mar 26, 2019
99afa10
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme Apr 1, 2019
f0bcebb
integrate master
dsyme Apr 14, 2019
849ead1
merge master
dsyme Apr 16, 2019
1475eae
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme May 22, 2019
d8501f1
Merge pull request #6824 from dotnet/merges/master-to-feature/implici…
May 23, 2019
e886cd8
Merge pull request #6837 from dotnet/merges/master-to-feature/implici…
May 24, 2019
5f56cd0
Merge pull request #6855 from dotnet/merges/master-to-feature/implici…
May 25, 2019
0e2ff8a
Merge branch 'release/fsharp47' of http://github.com/Microsoft/visual…
dsyme Jun 5, 2019
f038f6c
fix build
dsyme Jun 7, 2019
39dba18
address PR
dsyme Jun 7, 2019
625d859
fix test
dsyme Jun 14, 2019
eccd4d1
Merge branch 'release/fsharp47' of http://github.com/Microsoft/visual…
dsyme Jun 14, 2019
1e1fc63
Merge branch 'release/fsharp47' of https://github.com/dotnet/fsharp i…
dsyme Jul 3, 2019
a51817c
review feedback
dsyme Jul 3, 2019
dc62cfa
Merge pull request #7032 from dotnet/merges/master-to-feature/implici…
KevinRansom Jul 4, 2019
dd0aac0
Merge branch 'release/fsharp47' into feature/implicit-yields
KevinRansom Jul 4, 2019
eb90b69
make it match fsharp47
KevinRansom Jul 4, 2019
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
Prev Previous commit
Next Next commit
address PR
  • Loading branch information
dsyme committed Jun 7, 2019
commit 39dba18658d6c576b641c73cad3df6e31f6b0f27
1 change: 0 additions & 1 deletion src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ tcUseWhenPatternGuard,"Character range matches have been removed in F#. Consider
736,tcExprUndelayed,"TcExprUndelayed: delayed"
737,tcExpressionRequiresSequence,"This expression form may only be used in sequence and computation expressions"
738,tcInvalidObjectExpressionSyntaxForm,"Invalid object expression. Objects without overrides or interfaces should use the expression form 'new Type(args)' without braces."
#739,tcInvalidObjectSequenceOrRecordExpression,"Invalid object, sequence or record expression"
740,tcInvalidSequenceExpressionSyntaxForm,"Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'"
tcExpressionWithIfRequiresParenthesis,"This list or array expression includes an element of the form 'if ... then ... else'. Parenthesize this expression to indicate it is an individual element of the list or array, to disambiguate this from a list generated using a sequence expression"
741,tcUnableToParseFormatString,"Unable to parse format string '%s'"
Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6049,11 +6049,11 @@ and TcExprUndelayed cenv overallTy env tpenv (synExpr: SynExpr) =

// Used to implement the type-directed 'implicit yield' rule for computation expressions
| SynExpr.SequentialOrImplicitYield (sp, synExpr1, synExpr2, otherExpr, m) ->
let isStmt, e1', tpenv = TryTcStmt cenv env tpenv synExpr1
let isStmt, expr1, tpenv = TryTcStmt cenv env tpenv synExpr1
if isStmt then
let env = ShrinkContext env m synExpr2.Range
let e2', tpenv = TcExprThatCanBeCtorBody cenv overallTy env tpenv synExpr2
Expr.Sequential(e1', e2', NormalSeq, sp, m), tpenv
let expr2, tpenv = TcExprThatCanBeCtorBody cenv overallTy env tpenv synExpr2
Expr.Sequential(expr1, expr2, NormalSeq, sp, m), tpenv
else
// The first expression wasn't unit-typed, so proceed to the alternative interpretation
// Note a copy of the first expression is embedded in 'otherExpr' and thus
Expand Down
6 changes: 6 additions & 0 deletions tests/fsharp/typecheck/sigs/neg24.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ neg24.fs(312,33,312,34): typecheck error FS0020: The result of this expression h
neg24.fs(313,38,313,39): typecheck error FS0020: The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.

neg24.fs(313,47,313,48): typecheck error FS0020: The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.

neg24.fs(331,24,331,25): typecheck error FS0001: The 'if' expression needs to have type 'obj' to satisfy context type requirements. It currently has type 'int'.

neg24.fs(337,30,337,31): typecheck error FS0001: The 'if' expression needs to have type 'obj' to satisfy context type requirements. It currently has type 'int'.

neg24.fs(337,37,337,42): typecheck warning FS0020: The result of this expression has type 'obj' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.
52 changes: 39 additions & 13 deletions tests/fsharp/typecheck/sigs/neg24.fs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ module ArrayPositive2 =
[ printfn "hello"
if true then yield 1 else yield 2 ]

// check subsumption is alloed when using explicit yield
// check subsumption is allowed when using explicit yield
let l13 : obj list =
[ printfn "hello"
if true then yield 1 else yield 2 ]

// check subsumption is alloed when using explicit yield
// check subsumption is allowed when using explicit yield
let l14 : obj list =
[ printfn "hello"
if true then yield 1 ]
Expand Down Expand Up @@ -231,17 +231,17 @@ module BuilderPositive2 =
yield! empty
}

// Note, no subsumption is permitted when using yield in computation expressions, with or eithout implicit yield
//let v3c : L<obj> =
// list {
// printfn "hello"
// if true then 1 else obj()
// }
//let v3c : L<obj> =
// list {
// printfn "hello"
// if true then yield 1 else obj()
// }












let v3d =
list {
Expand Down Expand Up @@ -311,3 +311,29 @@ module ArrayNegative2 =
module SeqNegative2 =
let s5 = seq { if true then 1 else yield 2 } // expect warning about "1" being ignored. There is a 'yield' so statements are statements.
let s8 = seq { match 1 with 1 -> 4 | 2 -> 5 | 3 -> yield 6 | _ -> () } // expect warning about "4" being ignored. There is a 'yield' so statements are statements.

module BuilderNegative2 =
type L<'T> = { Make: (unit -> 'T list) }
let L f = { Make = f }

type ListBuilder() =
member __.Combine(x1: L<'T>, x2: L<'T>) = L(fun () -> x1.Make() @ x2.Make())
member __.Delay(f: unit -> L<'T>) = L(fun () -> f().Make())
member __.Zero() = L(fun () -> [])
member __.Yield(a: 'T) = L(fun () -> [a])
member __.YieldFrom(x: L<'T>) = x

let list = ListBuilder()

let v3c : L<obj> =
list {
printfn "hello"
if true then 1 else obj()
}

let v3c : L<obj> =
list {
printfn "hello"
if true then yield 1 else obj()
}