Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion docs/release-notes/.FSharp.Compiler.Service/11.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* Checking: Fix checking nested fields for records and anonymous ([PR #18964](https://github.com/dotnet/fsharp/pull/18964))
* Fix name is bound multiple times is not reported in 'as' pattern ([PR #18984](https://github.com/dotnet/fsharp/pull/18984))
* Fix: warn FS0049 on upper union case label. ([PR #19003](https://github.com/dotnet/fsharp/pull/19003))
* Type relations cache: handle potentially "infinite" types ([PR #19010](https://github.com/dotnet/fsharp/pull/19010))
* Type relations cache: handle potentially "infinite" types ([PR #19010](https://github.com/dotnet/fsharp/pull/19010))
* Check return type info in use! bindings ([PR #19024](https://github.com/dotnet/fsharp/pull/19024))

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,9 @@ let rec TryTranslateComputationExpression
match pat with
| SynPat.Named(ident = SynIdent(id, _); isThisVal = false) -> id, pat
| SynPat.LongIdent(longDotId = SynLongIdent(id = [ id ])) -> id, pat
| SynPat.Typed(pat = pat) when supportsTypedLetOrUseBang -> extractIdentifierFromPattern pat
| SynPat.Typed(innerPat, targetType, range) when supportsTypedLetOrUseBang ->
let ident, pat = extractIdentifierFromPattern innerPat
ident, SynPat.Typed(pat, targetType, unionRanges pat.Range range)
| SynPat.Wild(m) when supportsUseBangBindingValueDiscard ->
// To properly call the Using(disposable) CE member, we need to convert the wildcard to a SynPat.Named
let tmpIdent = mkSynId m "_"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ let testBindingPatterns() =
Disposable.Reset()

counterDisposable {
use! res:IDisposable = new Disposable(1)
use! __:IDisposable = new Disposable(2)
use! (res1: IDisposable) = new Disposable(3)
use! _: IDisposable = new Disposable(4)
use! (_: IDisposable) = new Disposable(5)
use! res:Disposable = new Disposable(1)
use! __:Disposable = new Disposable(2)
use! (res1: Disposable) = new Disposable(3)
use! _: Disposable = new Disposable(4)
use! (_: Disposable) = new Disposable(5)
return ()
} |> Async.RunSynchronously

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ module UseBangBindingsVersion9 =
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 3350, Line 40, Col 18, Line 40, Col 29, "Feature 'Allow let! and use! type annotations without requiring parentheses' is not available in F# 9.0. Please use language version 10.0 or greater.")
(Error 3350, Line 41, Col 17, Line 41, Col 28, "Feature 'Allow let! and use! type annotations without requiring parentheses' is not available in F# 9.0. Please use language version 10.0 or greater.")
(Error 3350, Line 43, Col 17, Line 43, Col 28, "Feature 'Allow let! and use! type annotations without requiring parentheses' is not available in F# 9.0. Please use language version 10.0 or greater.")
(Error 3350, Line 40, Col 18, Line 40, Col 28, "Feature 'Allow let! and use! type annotations without requiring parentheses' is not available in F# 9.0. Please use language version 10.0 or greater.")
(Error 3350, Line 41, Col 17, Line 41, Col 27, "Feature 'Allow let! and use! type annotations without requiring parentheses' is not available in F# 9.0. Please use language version 10.0 or greater.")
(Error 3350, Line 43, Col 17, Line 43, Col 27, "Feature 'Allow let! and use! type annotations without requiring parentheses' is not available in F# 9.0. Please use language version 10.0 or greater.")
]

module UseBangBindingsPreview =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,50 @@ match test() with
|> compileAndRun
|> shouldSucceed

[<Fact>]
let ``Preview: use! unresolved return type`` () =
FSharp """
module Test

open System.IO
open System.Threading.Tasks

task {
use! x: IDisposable = Task.FromResult(new StreamReader(""))
()
}
|> ignore
"""
|> withLangVersionPreview
|> typecheck
|> shouldFail
|> withDiagnostics [
Error 39, Line 8, Col 13, Line 8, Col 24, "The type 'IDisposable' is not defined."
]

[<Fact>]
let ``Preview: use! return type mismatch error 01`` () =
FSharp """
module Test

open System

task {
use! (x: int): IDisposable = failwith ""
()
}
|> ignore
"""
|> withLangVersionPreview
|> typecheck
|> shouldFail
|> withDiagnostics [
Error 1, Line 7, Col 11, Line 7, Col 17, "This expression was expected to have type
'IDisposable'
but here has type
'int' "
]

[<Theory; FileInlineData("tailcalls.fsx")>]
let ``tail call methods work`` compilation =
compilation
Expand Down
Loading