Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to release/dev17.12 #17520

Merged
merged 11 commits into from
Aug 12, 2024
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
6 changes: 5 additions & 1 deletion docs/release-notes/.FSharp.Compiler.Service/9.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
* Optimize simple mappings in comprehensions when the body of the mapping has `let`-bindings and/or sequential expressions before a single yield. ([PR #17419](https://github.com/dotnet/fsharp/pull/17419))
* C# protected property can be assigned in F# inherit constructor call. ([Issue #13299](https://github.com/dotnet/fsharp/issues/13299), [PR #17391](https://github.com/dotnet/fsharp/pull/17391))
* MethodAccessException on equality comparison of a record with private fields. ([Issue #17447](https://github.com/dotnet/fsharp/issues/17447), [PR #17391](https://github.com/dotnet/fsharp/pull/17467))
* Fix `function` implicit conversion. ([Issue #7401](https://github.com/dotnet/fsharp/issues/7401), [PR #17487](https://github.com/dotnet/fsharp/pull/17487))
* Compiler fails to recognise namespace in FQN with enabled GraphBasedChecking. ([Issue #17508](https://github.com/dotnet/fsharp/issues/17508), [PR #17510](https://github.com/dotnet/fsharp/pull/17510))
* Fix missing message for type error (FS0001). ([Issue #17373](https://github.com/dotnet/fsharp/issues/17373), [PR #17516](https://github.com/dotnet/fsharp/pull/17516))

### Added

* Support for nullable reference types ([PR #15181](https://github.com/dotnet/fsharp/pull/15181))
* Parser: recover on missing union case fields (PR [#17452](https://github.com/dotnet/fsharp/pull/17452))
* Parser: recover on missing union case field types (PR [#17455](https://github.com/dotnet/fsharp/pull/17455))
* Sink: report function domain type ([PR #17470](https://github.com/dotnet/fsharp/pull/17470))
* Render C# nullable-analysis attributes in tooltips ([PR #17485](https://github.com/dotnet/fsharp/pull/17485))

### Changed

Expand All @@ -21,5 +25,5 @@
* Optimize metadata reading for type members and custom attributes. ([PR #17364](https://github.com/dotnet/fsharp/pull/17364))
* Enforce `AttributeTargets` on unions. ([PR #17389](https://github.com/dotnet/fsharp/pull/17389))
* Ensure that isinteractive multi-emit backing fields are not public. ([Issue #17439](https://github.com/dotnet/fsharp/issues/17438)), ([PR #17439](https://github.com/dotnet/fsharp/pull/17439))

* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
### Breaking Changes
4 changes: 3 additions & 1 deletion docs/release-notes/.FSharp.Core/9.0.100.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### Fixed
* Struct UnionCase doesn't seem to be a valid target for the DefaultAugmentationAttribute ([Issue #17499](https://github.com/dotnet/fsharp/issues/17499), [PR #17502](https://github.com/dotnet/fsharp/pull/17502))

### Added

Expand All @@ -8,6 +9,7 @@
### Changed
* Change compiler default setting realsig+ when building assemblies ([Issue #17384](https://github.com/dotnet/fsharp/issues/17384), [PR #17378](https://github.com/dotnet/fsharp/pull/17385))
* Change compiler default setting for compressedMetadata ([Issue #17379](https://github.com/dotnet/fsharp/issues/17379), [PR #17383](https://github.com/dotnet/fsharp/pull/17383))

* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
* Struct UnionCase doesn't seem to be a valid target for the DefaultAugmentationAttribute ([Issue #17499](https://github.com/dotnet/fsharp/issues/17499), [PR #17502](https://github.com/dotnet/fsharp/pull/17502))
### Breaking Changes

2 changes: 2 additions & 0 deletions docs/release-notes/.Language/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

### Added

### Changed
* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
1 change: 1 addition & 0 deletions docs/release-notes/.VisualStudio/17.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
### Changed

### Breaking Changes
* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
1 change: 1 addition & 0 deletions eng/SourceBuildPrebuiltBaseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<UsagePattern IdentityGlob="System.CodeDom/8.0.0" />
<UsagePattern IdentityGlob="System.Resources.Extensions/8.0.0" />
<UsagePattern IdentityGlob="System.Diagnostics.DiagnosticSource/8.0.0" />
<UsagePattern IdentityGlob="System.Threading.Tasks.Dataflow/8.0.0" />

<UsagePattern IdentityGlob="Microsoft.AspNetCore.App.Runtime.linux-x64/9.0.*" />
<UsagePattern IdentityGlob="Microsoft.NETCore.App.Crossgen2.linux-x64/9.0.*" />
Expand Down
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.24352.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24405.2">
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
<Sha>cc732c57199f725857c201da146525e3be6bc504</Sha>
<Sha>0d066e61a30c2599d0ced871ea45acf0e10571af</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.24405.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24408.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>2c829550b968e29389ce8392244da2b006d71301</Sha>
<Sha>60ae233c3d77f11c5fdb53e570b64d503b13ba59</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24405.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24408.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>2c829550b968e29389ce8392244da2b006d71301</Sha>
<Sha>60ae233c3d77f11c5fdb53e570b64d503b13ba59</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.23614.4">
Expand Down
2 changes: 1 addition & 1 deletion eng/common/darc-init.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
param (
$darcVersion = $null,
$versionEndpoint = 'https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16',
$versionEndpoint = 'https://maestro.dot.net/api/assets/darc-version?api-version=2020-02-20',
$verbosity = 'minimal',
$toolpath = $null
)
Expand Down
2 changes: 1 addition & 1 deletion eng/common/darc-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source="${BASH_SOURCE[0]}"
darcVersion=''
versionEndpoint='https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16'
versionEndpoint='https://maestro.dot.net/api/assets/darc-version?api-version=2020-02-20'
verbosity='minimal'

while [[ $# > 0 ]]; do
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.24405.1",
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24408.2",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
46 changes: 30 additions & 16 deletions src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9672,22 +9672,36 @@ and TcMethodApplicationThen
PropagateThenTcDelayed cenv overallTy env tpenv mWholeExpr (MakeApplicableExprNoFlex cenv expr) exprTy atomicFlag delayed

/// Infer initial type information at the callsite from the syntax of an argument, prior to overload resolution.
and GetNewInferenceTypeForMethodArg (cenv: cenv) env tpenv x =
and GetNewInferenceTypeForMethodArg (cenv: cenv) x =

let g = cenv.g

match x with
| SynExprParen(a, _, _, _) ->
GetNewInferenceTypeForMethodArg cenv env tpenv a
| SynExpr.AddressOf (true, a, _, m) ->
mkByrefTyWithInference g (GetNewInferenceTypeForMethodArg cenv env tpenv a) (NewByRefKindInferenceType g m)
| SynExpr.Lambda (body = a)
| SynExpr.DotLambda (expr = a) ->
mkFunTy g (NewInferenceType g) (GetNewInferenceTypeForMethodArg cenv env tpenv a)
| SynExpr.Quote (_, raw, a, _, _) ->
if raw then mkRawQuotedExprTy g
else mkQuotedExprTy g (GetNewInferenceTypeForMethodArg cenv env tpenv a)
| _ -> NewInferenceType g
let rec loopExpr expr cont : struct (_ * _) =
match expr with
| SynExprParen (a, _, _, _) ->
loopExpr a cont
| SynExpr.AddressOf (true, a, _, m) ->
loopExpr a (cont << fun struct (depth, ty) -> depth + 1, mkByrefTyWithInference g ty (NewByRefKindInferenceType g m))
| SynExpr.Lambda (body = a)
| SynExpr.DotLambda (expr = a) ->
loopExpr a (cont << fun struct (depth, ty) -> depth + 1, mkFunTy g (NewInferenceType g) ty)
| SynExpr.MatchLambda (matchClauses = SynMatchClause (resultExpr = a) :: clauses) ->
let loopClause a = loopExpr a (cont << fun struct (depth, ty) -> depth + 1, mkFunTy g (NewInferenceType g) ty)

// Look at all branches, keeping the one
// that gives us the most syntactic information.
(loopClause a, clauses)
||> List.fold (fun ((maxClauseDepth, _) as acc) (SynMatchClause (resultExpr = a)) ->
match loopClause a with
| clauseDepth, ty when clauseDepth > maxClauseDepth -> clauseDepth, ty
| _ -> acc)
| SynExpr.Quote (_, raw, a, _, _) ->
if raw then cont (0, mkRawQuotedExprTy g)
else loopExpr a (cont << fun struct (depth, ty) -> depth + 1, mkQuotedExprTy g ty)
| _ -> cont (0, NewInferenceType g)

let struct (_depth, ty) = loopExpr x id
ty

and CalledMethHasSingleArgumentGroupOfThisLength n (calledMeth: MethInfo) =
match calledMeth.NumArgs with
Expand Down Expand Up @@ -9722,7 +9736,7 @@ and UnifyMatchingSimpleArgumentTypes (cenv: cenv) (env: TcEnv) exprTy (calledMet
and TcMethodApplication_SplitSynArguments
(cenv: cenv)
(env: TcEnv)
tpenv
_tpenv
isProp
(candidates: MethInfo list)
(exprTy: OverallTy)
Expand Down Expand Up @@ -9750,7 +9764,7 @@ and TcMethodApplication_SplitSynArguments
else
unnamedCurriedCallerArgs, namedCurriedCallerArgs

let MakeUnnamedCallerArgInfo x = (x, GetNewInferenceTypeForMethodArg cenv env tpenv x, x.Range)
let MakeUnnamedCallerArgInfo x = (x, GetNewInferenceTypeForMethodArg cenv x, x.Range)

let singleMethodCurriedArgs =
match candidates with
Expand Down Expand Up @@ -9789,7 +9803,7 @@ and TcMethodApplication_SplitSynArguments
| _ ->
let unnamedCurriedCallerArgs = unnamedCurriedCallerArgs |> List.mapSquared MakeUnnamedCallerArgInfo
let namedCurriedCallerArgs = namedCurriedCallerArgs |> List.mapSquared (fun (isOpt, nm, x) ->
let ty = GetNewInferenceTypeForMethodArg cenv env tpenv x
let ty = GetNewInferenceTypeForMethodArg cenv x
// #435263: compiler crash with .net optional parameters and F# optional syntax
// named optional arguments should always have option type
// STRUCT OPTIONS: if we allow struct options as optional arguments then we should relax this and rely
Expand Down
49 changes: 45 additions & 4 deletions src/Compiler/Checking/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module internal PrintUtilities =

let squareAngleL x = LeftL.leftBracketAngle ^^ x ^^ RightL.rightBracketAngle

let squareAngleReturn x = LeftL.leftBracketAngle ^^ WordL.keywordReturn ^^ SepL.colon ^^ x ^^ RightL.rightBracketAngle

let angleL x = SepL.leftAngle ^^ x ^^ RightL.rightAngle

let braceL x = wordL leftBrace ^^ x ^^ wordL rightBrace
Expand Down Expand Up @@ -638,6 +640,23 @@ module PrintTypes =
let argsL = bracketL (sepListL RightL.comma (List.map (layoutILAttribElement denv) args))
PrintIL.layoutILType denv [] ty ++ argsL

/// Layout nullness attributes for C# flow-analysis
/// F# does not process them, this way we can at least show them.
and layoutCsharpCodeAnalysisIlAttributes denv (attrs:ILAttributes) (layoutCombinator: Layout -> Layout -> Layout) restL =
let denvShortNames() = { denv with shortTypeNames = true }
let attrsL =
[ for a in attrs.AsArray() do
let name = a.Method.DeclaringType.BasicQualifiedName
if name.StartsWith("System.Diagnostics.CodeAnalysis") then
let parms, _args = decodeILAttribData a
layoutILAttrib (denvShortNames()) (a.Method.DeclaringType, parms)
]
match attrsL with
| [] -> restL
| _ ->
let separated = sepListL RightL.semicolon attrsL
layoutCombinator separated restL

/// Layout '[<attribs>]' above another block
and layoutAttribs denv startOpt isLiteral kind attrs restL =

Expand Down Expand Up @@ -1638,11 +1657,33 @@ module InfoMemberPrinting =
let idL = ConvertValLogicalNameToDisplayLayout false (tagMethod >> tagNavArbValRef minfo.ArbitraryValRef >> wordL) minfo.LogicalName
SepL.dot ^^
PrintTypes.layoutTyparDecls denv idL true minfo.FormalMethodTypars ^^
SepL.leftParen
SepL.leftParen

let layout,paramLayouts =
match denv.showCsharpCodeAnalysisAttributes, minfo with
| true, ILMeth(_g,mi,_e) ->
let methodLayout =
// Render Method attributes and [return:..] attributes on separate lines above (@@) the method definition
PrintTypes.layoutCsharpCodeAnalysisIlAttributes denv (minfo.GetCustomAttrs()) (squareAngleL >> (@@)) layout
|> PrintTypes.layoutCsharpCodeAnalysisIlAttributes denv (mi.RawMetadata.Return.CustomAttrs) (squareAngleReturn >> (@@))
let paramLayouts =
minfo.GetParamDatas (amap, m, minst)
|> List.head
|> List.zip (mi.ParamMetadata)
|> List.map(fun (ilParams,paramData) ->
layoutParamData denv paramData
// Render parameter attributes next to (^^) the parameter definition
|> PrintTypes.layoutCsharpCodeAnalysisIlAttributes denv (ilParams.CustomAttrs) (squareAngleL >> (^^)) )
methodLayout,paramLayouts
| _ ->
layout,
minfo.GetParamDatas (amap, m, minst)
|> List.concat
|> List.map (layoutParamData denv)


let paramDatas = minfo.GetParamDatas (amap, m, minst)
let layout = layout ^^ sepListL RightL.comma ((List.concat >> List.map (layoutParamData denv)) paramDatas)
layout ^^ RightL.rightParen ^^ WordL.colon ^^ PrintTypes.layoutType denv retTy
let layout = layout ^^ sepListL RightL.comma paramLayouts
layout ^^ RightL.rightParen ^^ WordL.colon ^^ PrintTypes.layoutType denv retTy // Todo enrich return type

// Prettify an ILMethInfo
let prettifyILMethInfo (amap: Import.ImportMap) m (minfo: MethInfo) typarInst ilMethInfo =
Expand Down
7 changes: 6 additions & 1 deletion src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ type Exception with

| ErrorFromAddingTypeEquation(error = ConstraintSolverError _ as e) -> e.Output(os, suggestNames)

| ErrorFromAddingTypeEquation(_g, denv, ty1, ty2, ConstraintSolverTupleDiffLengths(_, contextInfo, tl1, tl2, _, _), m) ->
| ErrorFromAddingTypeEquation(_g, denv, ty1, ty2, ConstraintSolverTupleDiffLengths(_, contextInfo, tl1, tl2, m1, m2), m) ->
let ty1, ty2, tpcs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2
let messageArgs = tl1.Length, ty1, tl2.Length, ty2

Expand All @@ -826,6 +826,11 @@ type Exception with
else
os.AppendString(FSComp.SR.listElementHasWrongTypeTuple messageArgs)
| _ -> os.AppendString(ErrorFromAddingTypeEquationTuplesE().Format tl1.Length ty1 tl2.Length ty2 tpcs)
else
os.AppendString(ConstraintSolverTupleDiffLengthsE().Format tl1.Length tl2.Length)

if m1.StartLine <> m2.StartLine then
os.AppendString(SeeAlsoE().Format(stringOfRange m1))

| ErrorFromAddingTypeEquation(g, denv, ty1, ty2, e, _) ->
if not (typeEquiv g ty1 ty2) then
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Driver/GraphChecking/FileContentMapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ let visitPat (p: SynPat) : FileContentEntry list =
match p with
| NameofPat moduleNameIdent -> continuation [ visitNameofResult moduleNameIdent ]
| SynPat.Paren(pat = pat) -> visit pat continuation
| SynPat.Typed(pat = pat; targetType = t) -> visit pat (fun nodes -> nodes @ visitSynType t)
| SynPat.Typed(pat = pat; targetType = t) -> visit pat (fun nodes -> nodes @ visitSynType t |> continuation)
| SynPat.Const _ -> continuation []
| SynPat.Wild _ -> continuation []
| SynPat.Named _ -> continuation []
Expand Down
Loading
Loading