Skip to content

Commit 8a47c17

Browse files
authored
Computational expressions tail calls support, revived (#18804)
1 parent fa4444c commit 8a47c17

24 files changed

+666
-123
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### Added
22
* Add opt-in warning attribute not valid for union case with fields [PR #18532](https://github.com/dotnet/fsharp/pull/18532))
33
* Add support for `when 'T : Enum` library-only static optimization constraint. ([PR #18546](https://github.com/dotnet/fsharp/pull/18546))
4+
* Add support for tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804))
45
* Add `--typecheck-only` flag support for F# Interactive (FSI) scripts to type-check without execution. ([Issue #18686](https://github.com/dotnet/fsharp/issues/18686))
56

67
### Fixed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Scoped Nowarn: added the #warnon compiler directive ([Language suggestion #278](https://github.com/fsharp/fslang-suggestions/issues/278), [RFC FS-1146 PR](https://github.com/fsharp/fslang-design/pull/782), [PR #18049](https://github.com/dotnet/fsharp/pull/18049))
1111
* Allow `let!`, `use!`, `and!` type annotations without requiring parentheses (([PR #18508](https://github.com/dotnet/fsharp/pull/18508) and [PR #18682](https://github.com/dotnet/fsharp/pull/18682)))
1212
* Exception names are now validated for illegal characters using the same mechanism as types/modules/namespaces ([Issue #18763](https://github.com/dotnet/fsharp/issues/18763))
13+
* Support tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804))
1314

1415
### Fixed
1516

src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

Lines changed: 84 additions & 121 deletions
Large diffs are not rendered by default.

src/Compiler/FSComp.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,4 +1807,5 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an
18071807
3875,lexWarnDirectiveMustHaveArgs,"Warn directives must have warning number(s) as argument(s)"
18081808
3876,lexWarnDirectivesMustMatch,"There is another %s for this warning already in line %d."
18091809
3877,lexLineDirectiveMappingIsNotUnique,"The file '%s' was also pointed to in a line directive in '%s'. Proper warn directive application may not be possible."
1810-
3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields."
1810+
3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields."
1811+
featureReturnFromFinal,"Support for ReturnFromFinal/YieldFromFinal in computation expressions to enable tailcall optimization when available on the builder."

src/Compiler/Facilities/LanguageFeatures.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ type LanguageFeature =
103103
| BetterAnonymousRecordParsing
104104
| ScopedNowarn
105105
| AllowTypedLetUseAndBang
106+
| ReturnFromFinal
106107

107108
/// LanguageVersion management
108109
type LanguageVersion(versionText) =
@@ -238,6 +239,7 @@ type LanguageVersion(versionText) =
238239
LanguageFeature.AllowTypedLetUseAndBang, languageVersion100
239240
LanguageFeature.UnmanagedConstraintCsharpInterop, languageVersion100
240241
LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, languageVersion100
242+
LanguageFeature.ReturnFromFinal, languageVersion100
241243

242244
// F# preview (still preview in 10.0)
243245
LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work
@@ -409,6 +411,7 @@ type LanguageVersion(versionText) =
409411
| LanguageFeature.BetterAnonymousRecordParsing -> FSComp.SR.featureBetterAnonymousRecordParsing ()
410412
| LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn ()
411413
| LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens ()
414+
| LanguageFeature.ReturnFromFinal -> FSComp.SR.featureReturnFromFinal ()
412415

413416
/// Get a version string associated with the given feature.
414417
static member GetFeatureVersionString feature =

src/Compiler/Facilities/LanguageFeatures.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ type LanguageFeature =
9494
| BetterAnonymousRecordParsing
9595
| ScopedNowarn
9696
| AllowTypedLetUseAndBang
97+
| ReturnFromFinal
9798

9899
/// LanguageVersion management
99100
type LanguageVersion =

src/Compiler/SyntaxTree/SyntaxTrivia.fsi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ type SynExprYieldOrReturnFromTrivia =
186186
YieldOrReturnFromKeyword: range
187187
}
188188

189+
static member Zero: SynExprYieldOrReturnFromTrivia
190+
189191
/// Represents additional information for SynExpr.AnonRecd
190192
[<NoEquality; NoComparison>]
191193
type SynExprAnonRecdTrivia =

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.

0 commit comments

Comments
 (0)