Skip to content

Commit

Permalink
Merge branch 'main' into fix-7491
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp authored Jan 14, 2025
2 parents 80ef337 + b2f2065 commit 822da08
Show file tree
Hide file tree
Showing 196 changed files with 26,922 additions and 3,851 deletions.
3 changes: 3 additions & 0 deletions .fantomasignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ src/Compiler/Checking/SignatureConformance.fs
src/Compiler/Checking/TypeHierarchy.fs
src/Compiler/Checking/TypeRelations.fs

# nullness-related problems
src/Compiler/DependencyManager/DependencyProvider.fs

# Incorrectly formatted: https://github.com/dotnet/fsharp/pull/14645/commits/49443a67ea8a17670c8a7c80c8bdf91f82231e91 or https://github.com/fsprojects/fantomas/issues/2733
# This CompilerImports.fs behavior is not fixed yet, following up in https://github.com/fsprojects/fantomas/issues/2733
src/Compiler/Driver/CompilerImports.fs
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,9 @@ tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstanda
/tests/AheadOfTime/Trimming/output.txt
*.svclog
micro.exe
positive.exe
positive.exe
/tests/FSharp.Compiler.ComponentTests/FSharpChecker/StandardError.txt
/tests/FSharp.Compiler.ComponentTests/FSharpChecker/StandardOutput.txt

# ilverify baseline result files
*.bsl.actual
27 changes: 27 additions & 0 deletions DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,33 @@ Linux/macOS:
export TEST_UPDATE_BSL=1
```

## Retain Test run built artifacts

When investigating tests issues it is sometimes useful to examine the artifacts built when running tests. Those built using the newer test framework are usually,
built in the %TEMP%\FSharp.Test.Utilities subdirectory.

To tell the test framework to not cleanup these files use the: FSHARP_RETAIN_TESTBUILDS environment variable

Windows:

CMD:

```shell
set FSHARP_RETAIN_TESTBUILDS=1
```

PowerShell:

```shell
$env:FSHARP_RETAIN_TESTBUILDS=1
```

Linux/macOS:

```shell
export FSHARP_RETAIN_TESTBUILDS=1
```

Next, run a build script build (debug or release, desktop or coreclr, depending which baselines you need to update), and test as described [above](#Testing-from-the-command-line). For example:

`./Build.cmd -c Release -testCoreClr` to update Release CoreCLR baselines.
Expand Down
6 changes: 4 additions & 2 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Fix Realsig+ generates nested closures with incorrect Generic ([Issue #17797](https://github.com/dotnet/fsharp/issues/17797), [PR #17877](https://github.com/dotnet/fsharp/pull/17877))
* Fix missing TailCall warning in Sequential in use scope ([PR #17927](https://github.com/dotnet/fsharp/pull/17927))
* Fix false negatives for passing null to "obj" arguments. Only "obj | null" can now subsume any type ([PR #17757](https://github.com/dotnet/fsharp/pull/17757))
* Fix internal error when calling 'AddSingleton' and other overloads only differing in generic arity ([PR #17804](https://github.com/dotnet/fsharp/pull/17804))
Expand All @@ -21,6 +22,7 @@
* Completion: fix qualified completion in sequence expressions [PR #18111](https://github.com/dotnet/fsharp/pull/18111)
* Symbols: try to use ValReprInfoForDisplay in Mfv.CurriedParameterGroups ([PR #18124](https://github.com/dotnet/fsharp/pull/18124))
* Shim/file system: fix leaks of the shim [PR #18144](https://github.com/dotnet/fsharp/pull/18144)
* fsi: fix auto-loading of script file inside NuGet package ([PR #18177](https://github.com/dotnet/fsharp/pull/18177))
* Fix for `Obsolete` attribute warning/error not taken into account when used with a unit of measure [PR #18182](https://github.com/dotnet/fsharp/pull/18182)

### Added
Expand Down Expand Up @@ -53,8 +55,8 @@
* Better ranges for #nowarn error reporting; bring back #nowarn warnings for --langVersion:80; add warnings under feature flag ([PR #17871](https://github.com/dotnet/fsharp/pull/17871))
* CheckAndThrow can be invoked only from within Cancellable context ([PR #18037](https://github.com/dotnet/fsharp/pull/18037))
* Make ILTypeDef base type calculation lazy. ([PR #18005](https://github.com/dotnet/fsharp/pull/18005))
* "#if" directive around nullness removed from src/Compiler/TypedTree/TypedTreePickle.fs and refactored. ([PR #18203](https://github.com/dotnet/fsharp/pull/18203))
* Removed redundant hash directives around nullness syntax ([Issue #18601](https://github.com/dotnet/fsharp/issues/18061), [PR #18203](https://github.com/dotnet/fsharp/pull/18203), [PR #18207](https://github.com/dotnet/fsharp/pull/18207))

### Breaking Changes

* Aliasing `StructAttribute` will now produce a warning (part of [Language suggestion #1136](https://github.com/fsharp/fslang-suggestions/issues/1136), [PR #18098](https://github.com/dotnet/fsharp/pull/18098))
* Aliasing `StructAttribute` will now produce a warning (part of [Language suggestion #1136](https://github.com/fsharp/fslang-suggestions/issues/1136), [PR #18098](https://github.com/dotnet/fsharp/pull/18098))
12 changes: 12 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Fixed

* Fix Realsig+ generates nested closures with incorrect Generic ([Issue #17797](https://github.com/dotnet/fsharp/issues/17797), [PR #17877](https://github.com/dotnet/fsharp/pull/17877))

### Added


### Changed


### Breaking Changes

12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24619.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.25060.3">
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
<Sha>e2b1d16fd66540b3a5813ec0ac1fd166688c3e0a</Sha>
<Sha>f5fa796273e4e59926e3fab26e1ab9e7d577f5e5</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<!-- Intermediate is necessary for source build. -->
Expand Down Expand Up @@ -42,14 +42,14 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24623.3">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25058.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e0e05154656254a735ebf19ffa5a37a8b915039b</Sha>
<Sha>8cc6ecd76c24ef6665579a5c5e386a211a1e7c54</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24623.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.25058.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e0e05154656254a735ebf19ffa5a37a8b915039b</Sha>
<Sha>8cc6ecd76c24ef6665579a5c5e386a211a1e7c54</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.24462.2">
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.2.2"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24623.3",
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25058.5",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
56 changes: 39 additions & 17 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ let ComputeTypeAccess (tref: ILTypeRef) hidden (accessibility: Accessibility) re

/// Indicates how type parameters are mapped to IL type variables
[<NoEquality; NoComparison>]
type TypeReprEnv(reprs: Map<Stamp, uint16>, count: int, templateReplacement: (TyconRef * ILTypeRef * Typars * TyparInstantiation) option) =
type TypeReprEnv
(reprs: Map<Stamp, (uint16 * Typar)>, count: int, templateReplacement: (TyconRef * ILTypeRef * Typars * TyparInstantiation) option) =

static let empty = TypeReprEnv(count = 0, reprs = Map.empty, templateReplacement = None)

Expand All @@ -536,7 +537,7 @@ type TypeReprEnv(reprs: Map<Stamp, uint16>, count: int, templateReplacement: (Ty
/// Lookup a type parameter
member _.Item(tp: Typar, m: range) =
try
reprs[tp.Stamp]
reprs[tp.Stamp] |> fst
with :? KeyNotFoundException ->
errorR (InternalError("Undefined or unsolved type variable: " + showL (typarL tp), m))
// Random value for post-hoc diagnostic analysis on generated tree *
Expand All @@ -546,7 +547,7 @@ type TypeReprEnv(reprs: Map<Stamp, uint16>, count: int, templateReplacement: (Ty
/// then it is ignored, since it doesn't correspond to a .NET type parameter.
member tyenv.AddOne(tp: Typar) =
if IsNonErasedTypar tp then
TypeReprEnv(reprs.Add(tp.Stamp, uint16 count), count + 1, templateReplacement)
TypeReprEnv(reprs.Add(tp.Stamp, (uint16 count, tp)), count + 1, templateReplacement)
else
tyenv

Expand All @@ -573,6 +574,14 @@ type TypeReprEnv(reprs: Map<Stamp, uint16>, count: int, templateReplacement: (Ty
/// Get the environment for generating a reference to items within a type definition
member eenv.ForTyconRef(tcref: TyconRef) = eenv.ForTycon tcref.Deref

/// Get a list of the Typars in this environment
member eenv.AsUserProvidedTypars() =
reprs
|> Map.toList
|> List.map (fun (_, (_, tp)) -> tp)
|> List.filter (fun tp -> not tp.IsCompilerGenerated)
|> Zset.ofList typarOrder

//--------------------------------------------------------------------------
// Generate type references
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -6904,14 +6913,6 @@ and GenFreevar cenv m eenvouter tyenvinner (fv: Val) =
and GetIlxClosureFreeVars cenv m (thisVars: ValRef list) boxity eenv takenNames expr =
let g = cenv.g

// Choose a base name for the closure
let basename =
let boundv = eenv.letBoundVars |> List.tryFind (fun v -> not v.IsCompilerGenerated)

match boundv with
| Some v -> v.CompiledName cenv.g.CompilerGlobalState
| None -> "clo"

// Get a unique stamp for the closure. This must be stable for things that can be part of a let rec.
let uniq =
match expr with
Expand All @@ -6921,18 +6922,34 @@ and GetIlxClosureFreeVars cenv m (thisVars: ValRef list) boxity eenv takenNames
| _ -> newUnique ()

// Choose a name for the closure
let ilCloTypeRef =
let ilCloTypeRef, initialFreeTyvars =
let boundvar =
eenv.letBoundVars |> List.tryFind (fun v -> not v.IsCompilerGenerated)

let basename =
match boundvar with
| Some v -> v.CompiledName cenv.g.CompilerGlobalState
| None -> "clo"

// FSharp 1.0 bug 3404: System.Reflection doesn't like '.' and '`' in type names
let basenameSafeForUseAsTypename = CleanUpGeneratedTypeName basename

let suffixmark = expr.Range

let cloName =
// Ensure that we have an g.CompilerGlobalState
assert (g.CompilerGlobalState |> Option.isSome)
g.CompilerGlobalState.Value.StableNameGenerator.GetUniqueCompilerGeneratedName(basenameSafeForUseAsTypename, suffixmark, uniq)
g.CompilerGlobalState.Value.StableNameGenerator.GetUniqueCompilerGeneratedName(basenameSafeForUseAsTypename, expr.Range, uniq)

let ilCloTypeRef = NestedTypeRefForCompLoc eenv.cloc cloName

NestedTypeRefForCompLoc eenv.cloc cloName
let initialFreeTyvars =
match g.realsig with
| true ->
{ emptyFreeTyvars with
FreeTypars = eenv.tyenv.AsUserProvidedTypars()
}
| false -> emptyFreeTyvars

ilCloTypeRef, initialFreeTyvars

// Collect the free variables of the closure
let cloFreeVarResults =
Expand All @@ -6943,7 +6960,12 @@ and GetIlxClosureFreeVars cenv m (thisVars: ValRef list) boxity eenv takenNames
| None -> opts
| Some(tcref, _, typars, _) -> opts.WithTemplateReplacement(tyconRefEq g tcref, typars)

freeInExpr opts expr
accFreeInExpr
opts
expr
{ emptyFreeVars with
FreeTyvars = initialFreeTyvars
}

// Partition the free variables when some can be accessed from places besides the immediate environment
// Also filter out the current value being bound, if any, as it is available from the "this"
Expand Down
12 changes: 6 additions & 6 deletions src/Compiler/DependencyManager/DependencyProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open System.Collections.Concurrent
module Option =

/// Convert string into Option string where null and String.Empty result in None
let ofString (s: string MaybeNull) =
let ofString (s: string | null) =
match s with
| null -> None
| "" -> None
Expand Down Expand Up @@ -607,7 +607,7 @@ type DependencyProvider
outputDir: string,
reportError: ResolvingErrorReport,
path: string
) : string MaybeNull * IDependencyManagerProvider MaybeNull =
) : string | null * IDependencyManagerProvider | null =
try
if path.Contains ":" && not (Path.IsPathRooted path) then
let managers =
Expand Down Expand Up @@ -637,7 +637,7 @@ type DependencyProvider
outputDir: string,
reportError: ResolvingErrorReport,
key: string
) : IDependencyManagerProvider MaybeNull =
) : IDependencyManagerProvider | null =
try
RegisteredDependencyManagers compilerTools (Option.ofString outputDir) reportError
|> Map.tryFind key
Expand All @@ -657,7 +657,7 @@ type DependencyProvider
packageManagerTextLines: (string * string) seq,
reportError: ResolvingErrorReport,
executionTfm: string,
[<Optional; DefaultParameterValue(null: string MaybeNull)>] executionRid: string MaybeNull,
[<Optional; DefaultParameterValue(null: string | null)>] executionRid: string | null,
[<Optional; DefaultParameterValue("")>] implicitIncludeDir: string,
[<Optional; DefaultParameterValue("")>] mainScriptName: string,
[<Optional; DefaultParameterValue("")>] fileName: string,
Expand All @@ -681,8 +681,8 @@ type DependencyProvider
try
let executionRid =
match executionRid with
| Null -> RidHelpers.platformRid
| NonNull executionRid -> executionRid
| null -> RidHelpers.platformRid
| executionRid -> executionRid

Ok(
packageManager.ResolveDependencies(
Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/DependencyManager/DependencyProvider.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type DependencyProvider =
packageManagerTextLines: (string * string) seq *
reportError: ResolvingErrorReport *
executionTfm: string *
[<Optional; DefaultParameterValue(null: string MaybeNull)>] executionRid: string *
[<Optional; DefaultParameterValue(null: string | null)>] executionRid: string *
[<Optional; DefaultParameterValue("")>] implicitIncludeDir: string *
[<Optional; DefaultParameterValue("")>] mainScriptName: string *
[<Optional; DefaultParameterValue("")>] fileName: string *
Expand All @@ -133,9 +133,9 @@ type DependencyProvider =
/// Fetch a dependencymanager that supports a specific key
member TryFindDependencyManagerByKey:
compilerTools: string seq * outputDir: string * reportError: ResolvingErrorReport * key: string ->
IDependencyManagerProvider MaybeNull
IDependencyManagerProvider | null

/// TryFindDependencyManagerInPath - given a #r "key:sometext" go and find a DependencyManager that satisfies the key
member TryFindDependencyManagerInPath:
compilerTools: string seq * outputDir: string * reportError: ResolvingErrorReport * path: string ->
string MaybeNull * IDependencyManagerProvider MaybeNull
string | null * IDependencyManagerProvider | null
5 changes: 2 additions & 3 deletions src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ module OldStyleMessages =
let ConstraintSolverTupleDiffLengthsE () = Message("ConstraintSolverTupleDiffLengths", "%d%d")
let ConstraintSolverInfiniteTypesE () = Message("ConstraintSolverInfiniteTypes", "%s%s")
let ConstraintSolverMissingConstraintE () = Message("ConstraintSolverMissingConstraint", "%s")
let ConstraintSolverNullnessWarningEquivWithTypesE () = Message("ConstraintSolverNullnessWarningEquivWithTypes", "%s%s")
let ConstraintSolverNullnessWarningEquivWithTypesE () = Message("ConstraintSolverNullnessWarningEquivWithTypes", "%s")
let ConstraintSolverNullnessWarningWithTypesE () = Message("ConstraintSolverNullnessWarningWithTypes", "%s%s")
let ConstraintSolverNullnessWarningWithTypeE () = Message("ConstraintSolverNullnessWarningWithType", "%s")
let ConstraintSolverNullnessWarningE () = Message("ConstraintSolverNullnessWarning", "%s")
Expand Down Expand Up @@ -678,8 +678,7 @@ type Exception with

let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2

os.Append(ConstraintSolverNullnessWarningEquivWithTypesE().Format t1 t2)
|> ignore
os.Append(ConstraintSolverNullnessWarningEquivWithTypesE().Format t1) |> ignore

if m.StartLine <> m2.StartLine then
os.Append(SeeAlsoE().Format(stringOfRange m)) |> ignore
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/FSStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<value>A type parameter is missing a constraint '{0}'</value>
</data>
<data name="ConstraintSolverNullnessWarningEquivWithTypes" xml:space="preserve">
<value>Nullness warning: The types '{0}' and '{1}' do not have equivalent nullability.</value>
<value>Nullness warning: A non-nullable '{0}' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression.</value>
</data>
<data name="ConstraintSolverNullnessWarningWithTypes" xml:space="preserve">
<value>Nullness warning: The types '{0}' and '{1}' do not have compatible nullability.</value>
Expand Down
4 changes: 3 additions & 1 deletion src/Compiler/TypedTree/CompilerGlobalState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ let newUnique() = System.Threading.Interlocked.Increment &uniqueCount
/// Unique name generator for stamps attached to to val_specs, tycon_specs etc.
//++GLOBAL MUTABLE STATE (concurrency-safe)
let mutable private stampCount = 0L
let newStamp() = System.Threading.Interlocked.Increment &stampCount
let newStamp() =
let stamp = System.Threading.Interlocked.Increment &stampCount
stamp
3 changes: 3 additions & 0 deletions src/Compiler/TypedTree/TypedTreeOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,9 @@ val accFreeInDecisionTree: FreeVarOptions -> DecisionTree -> FreeVars -> FreeVar
/// Get the free variables in a module definition.
val freeInModuleOrNamespace: FreeVarOptions -> ModuleOrNamespaceContents -> FreeVars

/// Get the free variables in an expression with accumulator
val accFreeInExpr: FreeVarOptions -> Expr -> FreeVars -> FreeVars

/// Get the free variables in an expression.
val freeInExpr: FreeVarOptions -> Expr -> FreeVars

Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSStrings.cs.xlf

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

Loading

0 comments on commit 822da08

Please sign in to comment.