Skip to content

Commit 85a3401

Browse files
committed
Add LanguageFeature
1 parent 6b6e86f commit 85a3401

18 files changed

+75
-2
lines changed

src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,9 @@ let rec TryTranslateComputationExpression
17931793
let supportsUseBangBindingValueDiscard =
17941794
ceenv.cenv.g.langVersion.SupportsFeature LanguageFeature.UseBangBindingValueDiscard
17951795

1796+
let supportsTypedLetOrUseBang =
1797+
ceenv.cenv.g.langVersion.SupportsFeature LanguageFeature.UseBangBindingValueDiscard
1798+
17961799
// use! x = ...
17971800
// use! (x) = ...
17981801
// use! (__) = ...
@@ -1802,7 +1805,7 @@ let rec TryTranslateComputationExpression
18021805
match pat with
18031806
| SynPat.Named(ident = SynIdent(id, _); isThisVal = false) -> id, pat
18041807
| SynPat.LongIdent(longDotId = SynLongIdent(id = [ id ])) -> id, pat
1805-
| SynPat.Typed(pat = pat) -> extractIdentifierFromPattern pat
1808+
| SynPat.Typed(pat = pat) when supportsTypedLetOrUseBang -> extractIdentifierFromPattern pat
18061809
| SynPat.Wild(m) when supportsUseBangBindingValueDiscard ->
18071810
// To properly call the Using(disposable) CE member, we need to convert the wildcard to a SynPat.Named
18081811
let tmpIdent = mkSynId m "_"

src/Compiler/FSComp.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ featureSupportValueOptionsAsOptionalParameters,"Support ValueOption as valid typ
18001800
featureSupportWarnWhenUnitPassedToObjArg,"Warn when unit is passed to a member accepting `obj` argument, e.g. `Method(o:obj)` will warn if called via `Method()`."
18011801
featureUseBangBindingValueDiscard,"Allows use! _ = ... in computation expressions"
18021802
featureScopedNowarn,"Support for scoped enabling / disabling of warnings by #warn and #nowarn directives, also inside modules"
1803+
featureAllowTypedLetOrUseBang,"Allow typed let! and use! bindings in computation expressions"
18031804
3874,lexWarnDirectiveMustBeFirst,"#nowarn/#warnon directives must appear as the first non-whitespace characters on a line"
18041805
3875,lexWarnDirectiveMustHaveArgs,"Warn directives must have warning number(s) as argument(s)"
18051806
3876,lexWarnDirectivesMustMatch,"There is another %s for this warning already in line %d."

src/Compiler/Facilities/LanguageFeatures.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type LanguageFeature =
101101
| WarnWhenUnitPassedToObjArg
102102
| UseBangBindingValueDiscard
103103
| ScopedNowarn
104+
| AllowTypedLetOrUseBang
104105

105106
/// LanguageVersion management
106107
type LanguageVersion(versionText) =
@@ -233,6 +234,7 @@ type LanguageVersion(versionText) =
233234
LanguageFeature.WarnWhenUnitPassedToObjArg, previewVersion
234235
LanguageFeature.UseBangBindingValueDiscard, previewVersion
235236
LanguageFeature.ScopedNowarn, previewVersion
237+
LanguageFeature.AllowTypedLetOrUseBang, previewVersion
236238
]
237239

238240
static let defaultLanguageVersion = LanguageVersion("default")
@@ -397,6 +399,7 @@ type LanguageVersion(versionText) =
397399
| LanguageFeature.WarnWhenUnitPassedToObjArg -> FSComp.SR.featureSupportWarnWhenUnitPassedToObjArg ()
398400
| LanguageFeature.UseBangBindingValueDiscard -> FSComp.SR.featureUseBangBindingValueDiscard ()
399401
| LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn ()
402+
| LanguageFeature.AllowTypedLetOrUseBang -> FSComp.SR.featureAllowTypedLetOrUseBang ()
400403

401404
/// Get a version string associated with the given feature.
402405
static member GetFeatureVersionString feature =

src/Compiler/Facilities/LanguageFeatures.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ type LanguageFeature =
9292
| WarnWhenUnitPassedToObjArg
9393
| UseBangBindingValueDiscard
9494
| ScopedNowarn
95+
| AllowTypedLetOrUseBang
9596

9697
/// LanguageVersion management
9798
type LanguageVersion =

src/Compiler/xlf/FSComp.txt.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ja.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)