Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,20 @@ let rec TryTranslateComputationExpression
| _ -> error (Error(FSComp.SR.tcInvalidUseBangBinding (), pat.Range))

let ident, pat = extractIdentifierFromPattern pat
// Validate the pattern's type annotation by invoking TcPat (for its type-checking side effects)
let patEnvValidate = TcPatLinearEnv(ceenv.tpenv, NameMap.empty, Set.empty)
let patTyValidate = NewInferenceType cenv.g

let _ =
cenv.TcPat
AllIdsOK
cenv
ceenv.env
None
(TcPatValFlags(ValInline.Optional, permitInferTypars, noArgOrRetAttribs, false, None, false))
patEnvValidate
patTyValidate
pat

let bindExpr =
let consumeExpr =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
async {
use x: askjdhaskjd = failwith ""
use! x: askjdhaskjd = failwith ""

use! (x: askjdhaskjd) = failwith ""
use! _: askjdhaskjd = failwith ""
use! (_: askjdhaskjd) = failwith ""
return 5
}
|> ignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,20 @@ module UseBangBindingsPreview =
|> withLangVersion10
|> compileAndRun
|> shouldSucceed

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_UseBang01.fs"|])>]
let ``UseBangBindings - E_UseBang01_fs - Preview LangVersion`` compilation =
compilation
|> asExe
|> withLangVersion10
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 39, Line 2, Col 12, Line 2, Col 23, "The type 'askjdhaskjd' is not defined.")
(Error 39, Line 3, Col 13, Line 3, Col 24, "The type 'askjdhaskjd' is not defined.")
(Error 39, Line 5, Col 14, Line 5, Col 25, "The type 'askjdhaskjd' is not defined.")
(Error 39, Line 6, Col 13, Line 6, Col 24, "The type 'askjdhaskjd' is not defined.")
(Error 39, Line 7, Col 14, Line 7, Col 25, "The type 'askjdhaskjd' is not defined.")
]


Loading