Skip to content
Merged
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
2 changes: 1 addition & 1 deletion DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Running any of the above will build the latest changes and run tests against the

## Using your custom compiler to build this repository

By removing all the subfolders called `Proto` under `artifacts` and running the `build` script again, the proto compiler will include your changes.
By removing all the subfolders called `Bootstrap` or `Proto` under `artifacts` and running the `build` script again, the proto compiler will include your changes.

Once the "proto" compiler is built, it won't be built again, so you may want to perform those steps again to ensure your changes don't break building the compiler itself.

Expand Down
30 changes: 30 additions & 0 deletions VisualFSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.Editor.IntegrationTe
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Benchmarks.Common", "tests\benchmarks\FSharp.Benchmarks.Common\FSharp.Benchmarks.Common.fsproj", "{6734FC6F-B5F3-45E1-9A72-720378BB49C9}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MicroPerf", "tests\benchmarks\CompiledCodeBenchmarks\MicroPerf\MicroPerf.fsproj", "{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicroPerfCSharp", "tests\benchmarks\CompiledCodeBenchmarks\MicroPerf\CS\MicroPerfCSharp.csproj", "{9F9DD315-37DA-4413-928E-1CFC6924B64F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1005,6 +1009,30 @@ Global
{6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Release|Any CPU.Build.0 = Release|Any CPU
{6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Release|x86.ActiveCfg = Release|Any CPU
{6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Release|x86.Build.0 = Release|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|Any CPU.Build.0 = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|x86.ActiveCfg = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|x86.Build.0 = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|Any CPU.Build.0 = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|x86.ActiveCfg = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|x86.Build.0 = Debug|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|Any CPU.ActiveCfg = Release|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|Any CPU.Build.0 = Release|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|x86.ActiveCfg = Release|Any CPU
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|x86.Build.0 = Release|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|x86.ActiveCfg = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|x86.Build.0 = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|Any CPU.Build.0 = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|x86.ActiveCfg = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|x86.Build.0 = Debug|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|Any CPU.Build.0 = Release|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|x86.ActiveCfg = Release|Any CPU
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1084,6 +1112,8 @@ Global
{CBC96CC7-65AB-46EA-A82E-F6A788DABF80} = {F7876C9B-FB6A-4EFB-B058-D6967DB75FB2}
{E31F9B59-FCF1-4D04-8762-C7BB60285A7B} = {F7876C9B-FB6A-4EFB-B058-D6967DB75FB2}
{6734FC6F-B5F3-45E1-9A72-720378BB49C9} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
{9F9DD315-37DA-4413-928E-1CFC6924B64F} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {48EDBBBE-C8EE-4E3C-8B19-97184A487B37}
Expand Down
2 changes: 2 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Fix a false positive of the `[<TailCall>]` analysis in combination with `yield!`. ([PR #16933](https://github.com/dotnet/fsharp/pull/16933))
* Don't blow the stack when traversing deeply nested sequential expressions. ([PR #16882](https://github.com/dotnet/fsharp/pull/16882))
* Fix wrong range start of INTERP_STRING_END. ([PR #16774](https://github.com/dotnet/fsharp/pull/16774), [PR #16785](https://github.com/dotnet/fsharp/pull/16785))
* Fix missing warning for recursive calls in list comprehensions. ([PR #16652](https://github.com/dotnet/fsharp/pull/16652))
Expand Down Expand Up @@ -35,6 +36,7 @@
* Parser recovers on complex primary constructor patterns, better tree representation for primary constructor patterns. ([PR #16425](https://github.com/dotnet/fsharp/pull/16425))
* Name resolution: keep type vars in subsequent checks ([PR #16456](https://github.com/dotnet/fsharp/pull/16456))
* Higher-order-function-based API for working with the untyped abstract syntax tree. ([PR #16462](https://github.com/dotnet/fsharp/pull/16462))
* PrettyNaming: make `DoesIdentifierNeedBackticks` public ([PR #16613](https://github.com/dotnet/fsharp/pull/16613))
* Add switch to generate types and members with IL visibility that accurately represents their F# visibility. ([PR #15484](https://github.com/dotnet/fsharp/pull/15484)
* Allow returning bool instead of unit option for partial active patterns. ([Language suggestion #1041](https://github.com/fsharp/fslang-suggestions/issues/1041), [PR #16473](https://github.com/dotnet/fsharp/pull/16473))
* Symbols: Add GenericArguments to FSharpEntity ([PR #16470](https://github.com/dotnet/fsharp/pull/16470))
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24170.6">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24176.8">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>8e3e00a76f467cc262dc14f6466ab884b2c4eb96</Sha>
<Sha>48e9e0d2164de0535446809364724da8962123a6</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23475.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
Expand Down
3 changes: 2 additions & 1 deletion eng/common/templates-official/job/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,15 @@ jobs:

- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- ${{ if eq(parameters.enableMicrobuild, 'true') }}:
- task: MicroBuildSigningPlugin@3
- task: MicroBuildSigningPlugin@4
displayName: Install MicroBuild plugin
inputs:
signType: $(_SignType)
zipSources: false
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
env:
TeamName: $(_TeamName)
MicroBuildOutputFolderOverride: '$(Agent.TempDirectory)'
continueOnError: ${{ parameters.continueOnError }}
condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"perl": "5.38.0.1"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24170.6",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24176.8",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
7 changes: 7 additions & 0 deletions src/Compiler/Checking/TailCallChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ and CheckCall cenv args ctxts (tailCall: TailCall) =
| Expr.App _ -> Some(TailCall.YesFromExpr cenv.g e)
| IsAppInLambdaBody t -> Some t
| _ -> None
| Expr.App(args = args) ->
args
|> List.tryPick (fun a ->
match a with
| IsAppInLambdaBody t -> Some t
| _ -> None)

| _ -> None

// if we haven't already decided this is no tail call, try to detect CPS-like expressions
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/PrettyNaming.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ val IsIdentifierName: name: string -> bool
/// TBD: needs unit testing
val IsActivePatternName: name: string -> bool

val internal DoesIdentifierNeedBackticks: string -> bool
val DoesIdentifierNeedBackticks: string -> bool

/// Adds double backticks if necessary to make a valid identifier, e.g.
/// op_Addition --> op_Addition
Expand Down
9 changes: 8 additions & 1 deletion src/FSharp.Build/Microsoft.FSharp.NetSdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
</Choose>

<PropertyGroup>
<EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">false</EnableDefaultCompileItems> <!-- Do not glob F# source files -->
<EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">false</EnableDefaultCompileItems> <!-- Do not glob F# source files -->
<!--
It turns out that the project system discovers Folders as a consequence of <SomeItem Include="path to files" />
''''EnableDefaultNoneItems true'''' causes folders and .fsi files to be displayed in the wrong order. because
Discovers Folders as a consequence of ````<SomeItem Include="path to files" />```` which EnableDefaultNoneItems causes folders and .fsi files to be located in the solution folder
prior to the ````<Compile Include="" />```` in the .fsproj which messes with the display order in solution explorer.
-->
<EnableDefaultNoneItems Condition=" '$(EnableDefaultNoneItems)' == '' ">false</EnableDefaultNoneItems> <!-- Do not glob F# none items-->
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module flaterrors =

[<InlineData("--FlatErrors")>] //Invalid case
[<InlineData("--FLATERRORS")>] //Even more invalid case
[<InlineData("--flaterrors-")>] // no + allowed
[<InlineData("--flaterrors+")>] // no + allowed
[<InlineData("--flaterrors-")>] // no - allowed
[<Theory>]
let ``E_MultiLine04_fs`` (option: string) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1522,3 +1522,164 @@ namespace N
Message =
"The member or function 'reverse' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
]

[<FSharp.Test.FactForNETCOREAPP>]
let ``Don't warn for yield! call of rec func in seq`` () =
"""
namespace N

module M =

type SynExpr =
| Sequential of expr1 : SynExpr * expr2 : SynExpr
| NotSequential
member _.Range = 99

type SyntaxNode = SynExpr of SynExpr

type SyntaxVisitor () = member _.VisitExpr _ = None

let visitor = SyntaxVisitor ()
let dive expr range f = range, fun () -> Some expr
let traverseSynExpr _ expr = Some expr

[<TailCall>]
let rec traverseSequentials path expr =
seq {
match expr with
| SynExpr.Sequential(expr1 = expr1; expr2 = SynExpr.Sequential _ as expr2) ->
yield dive expr expr.Range (fun expr -> visitor.VisitExpr(path, traverseSynExpr path, (fun _ -> None), expr))
let path = SyntaxNode.SynExpr expr :: path
yield dive expr1 expr1.Range (traverseSynExpr path)
yield! traverseSequentials path expr2 // should not warn

| _ ->
yield dive expr expr.Range (traverseSynExpr path)
}
"""
|> FSharp
|> withLangVersion80
|> compile
|> shouldSucceed

[<FSharp.Test.FactForNETCOREAPP>]
let ``Warn for yield! call of rec func in list comprehension`` () =
"""
namespace N

module M =

type SynExpr =
| Sequential of expr1 : SynExpr * expr2 : SynExpr
| NotSequential
member _.Range = 99

type SyntaxNode = SynExpr of SynExpr

type SyntaxVisitor () = member _.VisitExpr _ = None

let visitor = SyntaxVisitor ()
let dive expr range f = range, fun () -> Some expr
let traverseSynExpr _ expr = Some expr

[<TailCall>]
let rec traverseSequentials path expr =
[
match expr with
| SynExpr.Sequential(expr1 = expr1; expr2 = SynExpr.Sequential _ as expr2) ->
// It's a nested sequential expression.
// Visit it, but make defaultTraverse do nothing,
// since we're going to traverse its descendants ourselves.
yield dive expr expr.Range (fun expr -> visitor.VisitExpr(path, traverseSynExpr path, (fun _ -> None), expr))

// Now traverse its descendants.
let path = SyntaxNode.SynExpr expr :: path
yield dive expr1 expr1.Range (traverseSynExpr path)
yield! traverseSequentials path expr2 // should warn

| _ ->
// It's not a nested sequential expression.
// Traverse it normally.
yield dive expr expr.Range (traverseSynExpr path)
]
"""
|> FSharp
|> withLangVersion80
|> compile
|> shouldFail
|> withResults [
{ Error = Warning 3569
Range = { StartLine = 32
StartColumn = 24
EndLine = 32
EndColumn = 54 }
Message =
"The member or function 'traverseSequentials' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
]

[<FSharp.Test.FactForNETCOREAPP>]
let ``Warn for yield! call of rec func in custom CE`` () =
"""
namespace N

module M =

type SynExpr =
| Sequential of expr1 : SynExpr * expr2 : SynExpr
| NotSequential
member _.Range = 99

type SyntaxNode = SynExpr of SynExpr

type SyntaxVisitor () = member _.VisitExpr _ = None

let visitor = SyntaxVisitor ()
let dive expr range f = range, fun () -> Some expr
let traverseSynExpr _ expr = Some expr

type ThingsBuilder() =

member _.Yield(x) = [ x ]

member _.Combine(currentThings, newThings) = currentThings @ newThings

member _.Delay(f) = f ()

member _.YieldFrom(x) = x

let things = ThingsBuilder()

[<TailCall>]
let rec traverseSequentials path expr =
things {
match expr with
| SynExpr.Sequential(expr1 = expr1; expr2 = SynExpr.Sequential _ as expr2) ->
// It's a nested sequential expression.
// Visit it, but make defaultTraverse do nothing,
// since we're going to traverse its descendants ourselves.
yield dive expr expr.Range (fun expr -> visitor.VisitExpr(path, traverseSynExpr path, (fun _ -> None), expr))

// Now traverse its descendants.
let path = SyntaxNode.SynExpr expr :: path
yield dive expr1 expr1.Range (traverseSynExpr path)
yield! traverseSequentials path expr2 // should warn

| _ ->
// It's not a nested sequential expression.
// Traverse it normally.
yield dive expr expr.Range (traverseSynExpr path)
}
"""
|> FSharp
|> withLangVersion80
|> compile
|> shouldFail
|> withResults [
{ Error = Warning 3569
Range = { StartLine = 43
StartColumn = 17
EndLine = 43
EndColumn = 68 }
Message =
"The member or function 'traverseSequentials' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
]
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ let x = lb {1; 2; if true then 3;}

[<Theory>]
[<InlineData("preview","BindReturn")>]
[<InlineData("preview","BindReturn")>]
[<InlineData("preview","WithoutBindReturn")>]
[<InlineData("4.7","BindReturn")>]
[<InlineData("4.7","WithoutBindReturn")>]
Expand Down Expand Up @@ -135,4 +134,4 @@ let _pythags = seqbuilder {{
code
|> FSharp
|> typecheck
|> shouldSucceed
|> shouldSucceed
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,30 @@ let v = 2
module B

do ignore (match "" with | nameof X.Y.Z -> () | _ -> ())
"""
(set [| 0 |])
]
scenario
"nameof type with generic parameters"
[
sourceFile
"A.fs"
"""
namespace A

module B =
module C =
type D = class end
"""
Set.empty
sourceFile
"Z.fs"
"""
module Z

open System.Threading.Tasks

let _ = nameof Task<A.B.C.D>
"""
(set [| 0 |])
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6049,6 +6049,7 @@ FSharp.Compiler.Syntax.ParserDetail: Int32 GetHashCode(System.Collections.IEqual
FSharp.Compiler.Syntax.ParserDetail: Int32 Tag
FSharp.Compiler.Syntax.ParserDetail: Int32 get_Tag()
FSharp.Compiler.Syntax.ParserDetail: System.String ToString()
FSharp.Compiler.Syntax.PrettyNaming: Boolean DoesIdentifierNeedBackticks(System.String)
FSharp.Compiler.Syntax.PrettyNaming: Boolean IsActivePatternName(System.String)
FSharp.Compiler.Syntax.PrettyNaming: Boolean IsCompilerGeneratedName(System.String)
FSharp.Compiler.Syntax.PrettyNaming: Boolean IsIdentifierFirstCharacter(Char)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6049,6 +6049,7 @@ FSharp.Compiler.Syntax.ParserDetail: Int32 GetHashCode(System.Collections.IEqual
FSharp.Compiler.Syntax.ParserDetail: Int32 Tag
FSharp.Compiler.Syntax.ParserDetail: Int32 get_Tag()
FSharp.Compiler.Syntax.ParserDetail: System.String ToString()
FSharp.Compiler.Syntax.PrettyNaming: Boolean DoesIdentifierNeedBackticks(System.String)
FSharp.Compiler.Syntax.PrettyNaming: Boolean IsActivePatternName(System.String)
FSharp.Compiler.Syntax.PrettyNaming: Boolean IsCompilerGeneratedName(System.String)
FSharp.Compiler.Syntax.PrettyNaming: Boolean IsIdentifierFirstCharacter(Char)
Expand Down
11 changes: 0 additions & 11 deletions tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Benchmarks.fs

This file was deleted.

Loading