Skip to content

Commit 3159664

Browse files
RFC FS-1033: Deprecate places where seq can be omitted (#17772)
* Treat `{ 1..10 }` as sequence expression * deprecate { start..finish } and { start..step..finish } * fix build part1 * 3873., chkDeprecatePlacesWhereSeqCanBeOmitted * more tests * release notes * reorg seq tests * Better check * fix merge conflicts * Add code fix for adding missing `seq` before `{…}` * More tests * Fmt * update release notes * more editor tests --------- Co-authored-by: Brian Rourke Boll <[email protected]>
1 parent 62328fc commit 3159664

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+940
-121
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Fix nullness inference for member val and other OO scenarios ([PR #17845](https://github.com/dotnet/fsharp/pull/17845))
99

1010
### Added
11-
11+
* Deprecate places where `seq` can be omitted. ([Language suggestion #1033](https://github.com/fsharp/fslang-suggestions/issues/1033), [PR #17772](https://github.com/dotnet/fsharp/pull/17772))
1212
* Support literal attribute on decimals ([PR #17769](https://github.com/dotnet/fsharp/pull/17769))
1313

1414
### Changed

docs/release-notes/.Language/preview.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### Added
22

33
* Better generic unmanaged structs handling. ([Language suggestion #692](https://github.com/fsharp/fslang-suggestions/issues/692), [PR #12154](https://github.com/dotnet/fsharp/pull/12154))
4+
* Deprecate places where `seq` can be omitted. ([Language suggestion #1033](https://github.com/fsharp/fslang-suggestions/issues/1033), [PR #17772](https://github.com/dotnet/fsharp/pull/17772))
45

56
### Fixed
67

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Fixed
2+
3+
### Added
4+
* Code fix for adding missing `seq`. ([PR #17772](https://github.com/dotnet/fsharp/pull/17772))
5+
6+
### Changed
7+
8+
### Breaking Changes

src/Compiler/Checking/Expressions/CheckExpressions.fs

+11
Original file line numberDiff line numberDiff line change
@@ -5891,6 +5891,17 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE
58915891
TcForEachExpr cenv overallTy env tpenv (seqExprOnly, isFromSource, pat, synEnumExpr, synBodyExpr, m, spFor, spIn, m)
58925892

58935893
| SynExpr.ComputationExpr (hasSeqBuilder, comp, m) ->
5894+
let isIndexRange = match comp with | SynExpr.IndexRange _ -> true | _ -> false
5895+
let deprecatedPlacesWhereSeqCanBeOmitted =
5896+
cenv.g.langVersion.SupportsFeature LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted
5897+
if
5898+
deprecatedPlacesWhereSeqCanBeOmitted
5899+
&& isIndexRange
5900+
&& not hasSeqBuilder
5901+
&& not cenv.g.compilingFSharpCore
5902+
then
5903+
warning (Error(FSComp.SR.chkDeprecatePlacesWhereSeqCanBeOmitted (), m))
5904+
58945905
let env = ExitFamilyRegion env
58955906
cenv.TcSequenceExpressionEntry cenv env overallTy tpenv (hasSeqBuilder, comp) m
58965907

src/Compiler/FSComp.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1783,4 +1783,6 @@ featureEmptyBodiedComputationExpressions,"Support for computation expressions wi
17831783
featureAllowAccessModifiersToAutoPropertiesGettersAndSetters,"Allow access modifiers to auto properties getters and setters"
17841784
3871,tcAccessModifiersNotAllowedInSRTPConstraint,"Access modifiers cannot be applied to an SRTP constraint."
17851785
featureAllowObjectExpressionWithoutOverrides,"Allow object expressions without overrides"
1786-
3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern."
1786+
3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern."
1787+
3873,chkDeprecatePlacesWhereSeqCanBeOmitted,"This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'"
1788+
featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted"

src/Compiler/Facilities/LanguageFeatures.fs

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ type LanguageFeature =
9494
| ParsedHashDirectiveArgumentNonQuotes
9595
| EmptyBodiedComputationExpressions
9696
| AllowObjectExpressionWithoutOverrides
97+
| DeprecatePlacesWhereSeqCanBeOmitted
9798

9899
/// LanguageVersion management
99100
type LanguageVersion(versionText) =
@@ -219,6 +220,7 @@ type LanguageVersion(versionText) =
219220
LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work
220221
LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion
221222
LanguageFeature.AllowObjectExpressionWithoutOverrides, previewVersion
223+
LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted, previewVersion
222224
]
223225

224226
static let defaultLanguageVersion = LanguageVersion("default")
@@ -375,6 +377,7 @@ type LanguageVersion(versionText) =
375377
| LanguageFeature.ParsedHashDirectiveArgumentNonQuotes -> FSComp.SR.featureParsedHashDirectiveArgumentNonString ()
376378
| LanguageFeature.EmptyBodiedComputationExpressions -> FSComp.SR.featureEmptyBodiedComputationExpressions ()
377379
| LanguageFeature.AllowObjectExpressionWithoutOverrides -> FSComp.SR.featureAllowObjectExpressionWithoutOverrides ()
380+
| LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted -> FSComp.SR.featureDeprecatePlacesWhereSeqCanBeOmitted ()
378381

379382
/// Get a version string associated with the given feature.
380383
static member GetFeatureVersionString feature =

src/Compiler/Facilities/LanguageFeatures.fsi

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type LanguageFeature =
8585
| ParsedHashDirectiveArgumentNonQuotes
8686
| EmptyBodiedComputationExpressions
8787
| AllowObjectExpressionWithoutOverrides
88+
| DeprecatePlacesWhereSeqCanBeOmitted
8889

8990
/// LanguageVersion management
9091
type LanguageVersion =

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

+11-1
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

+11-1
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

+11-1
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

+11-1
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

+11-1
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

+11-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ko.xlf

+11-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)