Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
ee4e19e
Add TailCall attribute
dawedawe May 25, 2023
3390880
Adjust error number after merge
dawedawe May 30, 2023
08b3714
add two test cases for type members
dawedawe May 30, 2023
c49018a
Don't try to split empty CurriedArgInfos
dawedawe May 30, 2023
a9eae39
Add more member tests
dawedawe May 31, 2023
44d17bf
seems like we need to build up the env.mustTailCall set earlier in th…
dawedawe May 31, 2023
94ac8da
Fix an error from migrating the old PR to current sources.
dawedawe May 31, 2023
b95a52b
As cenv is mutated in loops, doing "with" copies isn't that great as …
dawedawe Jun 1, 2023
2abeb9e
update baselines for FSharp.Core to include TailCallAttribute
dawedawe Jun 2, 2023
e2c1e52
warn for rec call in binding, still very WIP
dawedawe Jun 5, 2023
969cd09
- improve check for problematic bindings to tailcall attributed funct…
dawedawe Jun 6, 2023
f928d1a
improve seq support
dawedawe Jun 6, 2023
05b0e11
add language version flag
dawedawe Jun 6, 2023
1412beb
improve tests a bit
dawedawe Jun 7, 2023
247e06d
add tests for async expressions
dawedawe Jun 7, 2023
41b1493
add tests for module rec
dawedawe Jun 8, 2023
faae5c8
Improve handling of ModuleOrNamespaceContents.TMDefDo and extend testing
dawedawe Jun 12, 2023
9c2af46
suppress some invalid warnings by keeping track of ranges that are an…
dawedawe Jun 13, 2023
35b31e5
fix build
dawedawe Jun 13, 2023
193c91f
use Stamp instead of LogicalName as the Map key
dawedawe Jun 14, 2023
e42c6e7
fix error number after merge
dawedawe Jun 15, 2023
f678196
remove TailCall check code from PostInferenceChecks.fs
dawedawe Jun 27, 2023
d5c4822
Add new file TailCallChecks.fs to focus on tail call checks
dawedawe Jun 27, 2023
7693a61
first steps to remove limits calculations
dawedawe Jun 27, 2023
ac772f2
remove last bits of limits
dawedawe Jun 27, 2023
81e5b7e
don't bother with attribute checking here
dawedawe Jun 27, 2023
06717ce
remove more unneeded code
dawedawe Jun 27, 2023
6e347c3
small optimization
dawedawe Jun 27, 2023
08e5e7f
Adjust error number after main merge
dawedawe Jun 27, 2023
5123533
add TailCallChecks.fs to .fantomasignore
dawedawe Jun 27, 2023
295e311
remove last non-tailrec error reporting from dedicated file
dawedawe Jun 28, 2023
cf7f834
- add fsi file
dawedawe Jun 28, 2023
f648155
simplify
dawedawe Jun 28, 2023
fd5141e
Remove resumable checks
dawedawe Jun 29, 2023
cef7015
remove external handling
dawedawe Jun 29, 2023
fd21b38
remove isInAppExpr
dawedawe Jun 29, 2023
a5648cc
remove returnScope
dawedawe Jun 29, 2023
be8f6a7
remove boundTyparNames
dawedawe Jun 29, 2023
176b8c6
remove argVals from env
dawedawe Jun 29, 2023
927bcd0
let's drop quote and reflect, too, for now
dawedawe Jun 29, 2023
1473c95
remove usesQuotations
dawedawe Jun 29, 2023
5473838
get rid of range-based approach, collect TailRec-attributed bindings …
dawedawe Jun 29, 2023
5d22615
fold instead of mutate
dawedawe Jun 29, 2023
98f7195
format
dawedawe Jun 29, 2023
1bf7c7d
make tests more challenging
dawedawe Jul 3, 2023
65b7d4e
do the TailCall checks during the main traversal
dawedawe Jul 3, 2023
9614cfb
WIP: move TailCallChecks into main3 after optimization
dawedawe Jul 4, 2023
af2e5be
format
dawedawe Jul 4, 2023
48e0261
let TailCallChecks.fs be formatted
dawedawe Jul 4, 2023
e0e0aca
bring over support for TyLambda bodies from other branch
dawedawe Jul 4, 2023
0071767
adjust expected errors
dawedawe Jul 4, 2023
5b6ef34
fix the doubled error messages
dawedawe Jul 4, 2023
bcf5cb3
fix seq analysis
dawedawe Jul 4, 2023
2d30a42
cleanup
dawedawe Jul 4, 2023
85c83cd
cover some more rec constructs
dawedawe Jul 5, 2023
e278ed5
remove commented code from tests
dawedawe Jul 6, 2023
d80f74e
Rename the type "IsTailCall" to "TailCall"
dawedawe Jul 6, 2023
bd8a900
model boolean as dedicated type "TailCallReturnType"
dawedawe Jul 6, 2023
4898964
remove unused members of type "PermitByRefExpr"
dawedawe Jul 6, 2023
cc93eea
remove unused mustTailCallExprs from env
dawedawe Jul 6, 2023
444be5e
add comment to explain origin of PermitByRefExpr
dawedawe Jul 8, 2023
63c1ac7
First stab at support for continuation-passing-style
dawedawe Jul 8, 2023
09d5096
- refactor approach for CPS support to be much simpler
dawedawe Jul 9, 2023
c1d8936
one env ought to be enough for everyone
dawedawe Jul 9, 2023
ab401a4
report time for "TailCall Checks"
dawedawe Jul 10, 2023
0650a8d
clean up unused function args
dawedawe Jul 10, 2023
5d4cdc2
improve some comments and names
dawedawe Jul 10, 2023
3eef971
add API docs for TailCall attribute
dawedawe Jul 11, 2023
aaec214
add xml comment for TailCallChecks.CheckImplFile
dawedawe Jul 11, 2023
d68c8a4
Update src/FSharp.Core/prim-types.fsi
dawedawe Jul 11, 2023
ff6dff3
remove some superfluous stuff from CheckLambdas
dawedawe Jul 11, 2023
b696021
More detailed comment
dawedawe Jul 11, 2023
28a9b84
extend test with an inner class type
dawedawe Jul 11, 2023
da6851a
optimize
dawedawe Jul 11, 2023
6d03568
update xlf
dawedawe Jul 14, 2023
11bef39
adjust error messages after xlf update
dawedawe Jul 14, 2023
baa6ca5
revert white space changes that sneaked in during rebase
dawedawe Jul 14, 2023
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
792 changes: 792 additions & 0 deletions src/Compiler/Checking/TailCallChecks.fs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/Compiler/Checking/TailCallChecks.fsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module internal FSharp.Compiler.TailCallChecks

open FSharp.Compiler
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.TypedTree

/// Perform the TailCall analysis on the optimized TAST for a file.
/// The TAST is traversed analogously to the PostInferenceChecks phase.
/// For functions that are annotated with the [<TailCall>] attribute, a warning is emmitted if they are called in a
/// non-tailrecursive manner in the recursive scope of the function.
/// The ModuleOrNamespaceContents aren't mutated in any way by performing this check.
val CheckImplFile:
g: TcGlobals * amap: Import.ImportMap * reportErrors: bool * implFileContents: ModuleOrNamespaceContents -> unit
9 changes: 9 additions & 0 deletions src/Compiler/Driver/fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ open FSharp.Compiler.CreateILModule
open FSharp.Compiler.DependencyManager
open FSharp.Compiler.Diagnostics
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Features
open FSharp.Compiler.IlxGen
open FSharp.Compiler.InfoReader
open FSharp.Compiler.IO
Expand Down Expand Up @@ -878,6 +879,14 @@ let main3

optimizedImpls, EncodeOptimizationData(tcGlobals, tcConfig, outfile, exportRemapping, (generatedCcu, optimizationData), false)

if tcGlobals.langVersion.SupportsFeature LanguageFeature.WarningWhenTailRecAttributeButNonTailRecUsage then
match optimizedImpls with
| CheckedAssemblyAfterOptimization checkedImplFileAfterOptimizations ->
ReportTime tcConfig ("TailCall Checks")

for f in checkedImplFileAfterOptimizations do
TailCallChecks.CheckImplFile(tcGlobals, tcImports.GetImportMap(), true, f.ImplFile.Contents)

let refAssemblySignatureHash =
match tcConfig.emitMetadataAssembly with
| MetadataAssemblyGeneration.None -> None
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,7 @@ featureExtendedStringInterpolation,"Extended string interpolation similar to C#
featureWarningWhenMultipleRecdTypeChoice,"Raises warnings when multiple record type matches were found during name resolution because of overlapping field names."
featureImprovedImpliedArgumentNames,"Improved implied argument names"
featureStrictIndentation,"Raises errors on incorrect indentation, allows better recovery and analysis during editing"
featureChkNotTailRecursive,"Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way."
3353,fsiInvalidDirective,"Invalid directive '#%s %s'"
3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation."
3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation."
Expand Down Expand Up @@ -1700,4 +1701,5 @@ featureInformationalObjInferenceDiagnostic,"Diagnostic 3559 (warn when obj infer
3566,tcMultipleRecdTypeChoice,"Multiple type matches were found:\n%s\nThe type '%s' was used. Due to the overlapping field names\n%s\nconsider using type annotations or change the order of open statements."
3567,parsMissingMemberBody,"Expecting member body"
3568,parsMissingKeyword,"Missing keyword '%s'"
3569,chkNotTailRecursive,"The member or function '%s' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way."
3577,tcOverrideUsesMultipleArgumentsInsteadOfTuple,"This override takes a tuple instead of multiple arguments. Try to add an additional layer of parentheses at the method definition (e.g. 'member _.Foo((x, y))'), or remove parentheses at the abstract method declaration (e.g. 'abstract member Foo: 'a * 'b -> 'c')."
2 changes: 2 additions & 0 deletions src/Compiler/FSharp.Compiler.Service.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@
<Compile Include="Checking\QuotationTranslator.fs" />
<Compile Include="Checking\PostInferenceChecks.fsi" />
<Compile Include="Checking\PostInferenceChecks.fs" />
<Compile Include="Checking\TailCallChecks.fsi" />
<Compile Include="Checking\TailCallChecks.fs" />
<Compile Include="Checking\CheckBasics.fsi" />
<Compile Include="Checking\CheckBasics.fs" />
<Compile Include="Checking\CheckRecordSyntaxHelpers.fsi" />
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type LanguageFeature =
| WarningWhenMultipleRecdTypeChoice
| ImprovedImpliedArgumentNames
| DiagnosticForObjInference
| WarningWhenTailRecAttributeButNonTailRecUsage

/// LanguageVersion management
type LanguageVersion(versionText) =
Expand Down Expand Up @@ -165,6 +166,7 @@ type LanguageVersion(versionText) =
LanguageFeature.ImprovedImpliedArgumentNames, previewVersion
LanguageFeature.DiagnosticForObjInference, previewVersion
LanguageFeature.StrictIndentation, previewVersion
LanguageFeature.WarningWhenTailRecAttributeButNonTailRecUsage, previewVersion

]

Expand Down Expand Up @@ -291,6 +293,7 @@ type LanguageVersion(versionText) =
| LanguageFeature.ImprovedImpliedArgumentNames -> FSComp.SR.featureImprovedImpliedArgumentNames ()
| LanguageFeature.DiagnosticForObjInference -> FSComp.SR.featureInformationalObjInferenceDiagnostic ()
| LanguageFeature.StrictIndentation -> FSComp.SR.featureStrictIndentation ()
| LanguageFeature.WarningWhenTailRecAttributeButNonTailRecUsage -> FSComp.SR.featureChkNotTailRecursive ()

/// Get a version string associated with the given feature.
static member GetFeatureVersionString feature =
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type LanguageFeature =
| WarningWhenMultipleRecdTypeChoice
| ImprovedImpliedArgumentNames
| DiagnosticForObjInference
| WarningWhenTailRecAttributeButNonTailRecUsage

/// LanguageVersion management
type LanguageVersion =
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/TypedTree/TcGlobals.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,7 @@ type TcGlobals(
member val attrib_CompilerFeatureRequiredAttribute = findSysAttrib "System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute"
member val attrib_SetsRequiredMembersAttribute = findSysAttrib "System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute"
member val attrib_RequiredMemberAttribute = findSysAttrib "System.Runtime.CompilerServices.RequiredMemberAttribute"
member val attrib_TailCallAttribute = mk_MFCore_attrib "TailCallAttribute"

member g.improveType tcref tinst = improveTy tcref tinst

Expand Down
10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading