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 #17636

Merged
merged 10 commits into from
Aug 30, 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
2 changes: 2 additions & 0 deletions UseLocalCompiler.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
<FscToolPath Condition="'$(FscToolPath)' == ''">$([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH)))</FscToolPath>
<FscToolExe Condition="'$(FscToolExe)' == ''">$([System.IO.Path]::GetFileName($(DOTNET_HOST_PATH)))</FscToolExe>

<DotnetFscCompilerPath>$(LocalFSharpCompilerPath)/artifacts/bin/fsc/$(LocalFSharpCompilerConfiguration)/net9.0/fsc.dll</DotnetFscCompilerPath>
<Fsc_DotNET_DotnetFscCompilerPath>$(LocalFSharpCompilerPath)/artifacts/bin/fsc/$(LocalFSharpCompilerConfiguration)/net9.0/fsc.dll</Fsc_DotNET_DotnetFscCompilerPath>
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ stages:
- job: Linux
pool:
vmImage: $(UbuntuMachineQueueName)
timeoutInMinutes: 120
variables:
- name: _SignType
value: Test
Expand Down Expand Up @@ -586,6 +587,7 @@ stages:
- job: MacOS
pool:
vmImage: macos-12
timeoutInMinutes: 120
variables:
- name: _SignType
value: Test
Expand Down
3 changes: 3 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* MethodAccessException on equality comparison of a type private to module. ([Issue #17541](https://github.com/dotnet/fsharp/issues/17541), [PR #17548](https://github.com/dotnet/fsharp/pull/17548))
* Fixed checking failure when `global` namespace is involved with enabled GraphBasedChecking ([PR #17553](https://github.com/dotnet/fsharp/pull/17553))
* Add missing byte chars notations, enforce limits in decimal notation in byte char & string (Issues [#15867](https://github.com/dotnet/fsharp/issues/15867), [#15868](https://github.com/dotnet/fsharp/issues/15868), [#15869](https://github.com/dotnet/fsharp/issues/15869), [PR #15898](https://github.com/dotnet/fsharp/pull/15898))
* Parentheses analysis: keep extra parentheses around unit & tuples in method definitions. ([PR #17618](https://github.com/dotnet/fsharp/pull/17618))

### Added

Expand All @@ -35,4 +36,6 @@
* Applied nullable reference types to FSharp.Compiler.Service itself ([PR #15310](https://github.com/dotnet/fsharp/pull/15310))
* 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))
* Better error reporting for unions with duplicated fields. ([PR #17521](https://github.com/dotnet/fsharp/pull/17521))
* Optimize ILTypeDef interface impls reading from metadata. ([PR #17382](https://github.com/dotnet/fsharp/pull/17382))

### 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="10.0.0-alpha.1.24421.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="10.0.0-alpha.1.24426.2">
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
<Sha>bdd698774daa248301c236f09b97015610ca2842</Sha>
<Sha>6c26545ca7999a4192df6899ea9ed4eaa950d367</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.24423.2">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24426.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>91599268652b51969b8d8088d4f2f2ba7b3ebb19</Sha>
<Sha>e3bdd9a0f2a65fe037ba1adb2261eea48a840fa4</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24423.2">
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24426.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>91599268652b51969b8d8088d4f2f2ba7b3ebb19</Sha>
<Sha>e3bdd9a0f2a65fe037ba1adb2261eea48a840fa4</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 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.24423.2",
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24426.3",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
48 changes: 27 additions & 21 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,16 +1425,10 @@ let seekReadParamRow (ctxt: ILMetadataReader) mdv idx =
(flags, seq, nameIdx)

/// Read Table InterfaceImpl.
let private seekReadInterfaceImplRow (ctxt: ILMetadataReader) mdv idx =
let private seekReadInterfaceIdx (ctxt: ILMetadataReader) mdv idx =
let mutable addr = ctxt.rowAddr TableNames.InterfaceImpl idx
let tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
let intfIdx = seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr

struct {|
TypeIdx = tidx
IntfIdx = intfIdx
IntImplIdx = idx
|}
let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr

/// Read Table MemberRef.
let seekReadMemberRefRow (ctxt: ILMetadataReader) mdv idx =
Expand Down Expand Up @@ -1653,11 +1647,11 @@ let seekReadGenericParamRow (ctxt: ILMetadataReader) mdv idx =
(idx, seq, flags, ownerIdx, nameIdx)

// Read Table GenericParamConstraint.
let seekReadGenericParamConstraintRow (ctxt: ILMetadataReader) mdv idx =
let seekReadGenericParamConstraintIdx (ctxt: ILMetadataReader) mdv idx =
let mutable addr = ctxt.rowAddr TableNames.GenericParamConstraint idx
let pidx = seekReadUntaggedIdx TableNames.GenericParam ctxt mdv &addr
let _pidx = seekReadUntaggedIdx TableNames.GenericParam ctxt mdv &addr
let constraintIdx = seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr
(pidx, constraintIdx)
constraintIdx

/// Read Table ILMethodSpec.
let seekReadMethodSpecRow (ctxt: ILMetadataReader) mdv idx =
Expand Down Expand Up @@ -2248,11 +2242,16 @@ and seekReadNestedTypeDefs (ctxt: ILMetadataReader) tidx =
and seekReadInterfaceImpls (ctxt: ILMetadataReader) mdv numTypars tidx =
seekReadIndexedRows (
ctxt.getNumRows TableNames.InterfaceImpl,
seekReadInterfaceImplRow ctxt mdv,
(fun x -> x.TypeIdx),
simpleIndexCompare tidx,
id,
id,
(fun idx ->
let mutable addr = ctxt.rowAddr TableNames.InterfaceImpl idx
let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
simpleIndexCompare tidx _tidx),
isSorted ctxt TableNames.InterfaceImpl,
(fun x -> (seekReadTypeDefOrRef ctxt numTypars AsObject [] x.IntfIdx), (ctxt.customAttrsReader_InterfaceImpl, x.IntImplIdx))
(fun idx ->
let intfIdx = seekReadInterfaceIdx ctxt mdv idx
seekReadTypeDefOrRef ctxt numTypars AsObject [] intfIdx, (ctxt.customAttrsReader_InterfaceImpl, idx))
)

and seekReadGenericParams ctxt numTypars (a, b) : ILGenericParameterDefs =
Expand All @@ -2262,12 +2261,14 @@ and seekReadGenericParamsUncached ctxtH (GenericParamsIdx(numTypars, a, b)) =
let (ctxt: ILMetadataReader) = getHole ctxtH
let mdv = ctxt.mdfile.GetView()

let key = TaggedIndex(a, b)

let pars =
seekReadIndexedRows (
ctxt.getNumRows TableNames.GenericParam,
seekReadGenericParamRow ctxt mdv,
(fun (_, _, _, tomd, _) -> tomd),
tomdCompare (TaggedIndex(a, b)),
tomdCompare key,
isSorted ctxt TableNames.GenericParam,
(fun (gpidx, seq, flags, _, nameIdx) ->
let flags = int32 flags
Expand Down Expand Up @@ -2299,11 +2300,16 @@ and seekReadGenericParamsUncached ctxtH (GenericParamsIdx(numTypars, a, b)) =
and seekReadGenericParamConstraints (ctxt: ILMetadataReader) mdv numTypars gpidx =
seekReadIndexedRows (
ctxt.getNumRows TableNames.GenericParamConstraint,
seekReadGenericParamConstraintRow ctxt mdv,
fst,
simpleIndexCompare gpidx,
id,
id,
(fun idx ->
let mutable addr = ctxt.rowAddr TableNames.GenericParamConstraint idx
let pidx = seekReadUntaggedIdx TableNames.GenericParam ctxt mdv &addr
simpleIndexCompare gpidx pidx),
isSorted ctxt TableNames.GenericParamConstraint,
(snd >> seekReadTypeDefOrRef ctxt numTypars AsObject [])
(fun idx ->
let constraintIdx = seekReadGenericParamConstraintIdx ctxt mdv idx
seekReadTypeDefOrRef ctxt numTypars AsObject [] constraintIdx)
)

and seekReadTypeDefAsType (ctxt: ILMetadataReader) boxity (ginst: ILTypes) idx =
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Driver/CompilerConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ type TcConfigBuilder =
DumpGraph = false
}
dumpSignatureData = false
realsig = true
realsig = false
strictIndentation = None
}

Expand Down
52 changes: 34 additions & 18 deletions src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,7 @@ type FormattedDiagnosticDetailedInfo =
Canonical: FormattedDiagnosticCanonicalInformation
Message: string
Context: string option
DiagnosticStyle: DiagnosticStyle
}

[<RequireQualifiedAccess>]
Expand Down Expand Up @@ -2118,7 +2119,7 @@ let FormatDiagnosticLocation (tcConfig: TcConfig) (m: Range) : FormattedDiagnost
| DiagnosticStyle.Rich ->
let file = file.Replace('/', Path.DirectorySeparatorChar)
let m = withStart (mkPos m.StartLine (m.StartColumn + 1)) m
(sprintf "◦→ %s (%d,%d)" file m.StartLine m.StartColumn), m, file
(sprintf "\n --> %s (%d,%d)" file m.StartLine m.StartColumn), m, file

{
Range = m
Expand Down Expand Up @@ -2164,7 +2165,7 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
| DiagnosticStyle.Default
| DiagnosticStyle.Test -> sprintf "%s FS%04d: " message errorNumber
| DiagnosticStyle.VisualStudio -> sprintf "%s %s FS%04d: " subcategory message errorNumber
| DiagnosticStyle.Rich -> sprintf "\n◦→ %s FS%04d: " message errorNumber
| DiagnosticStyle.Rich -> sprintf "%s FS%04d: " message errorNumber

let canonical: FormattedDiagnosticCanonicalInformation =
{
Expand All @@ -2179,11 +2180,8 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
| DiagnosticStyle.Gcc
| DiagnosticStyle.Default
| DiagnosticStyle.Test
| DiagnosticStyle.Rich
| DiagnosticStyle.VisualStudio -> diagnostic.FormatCore(tcConfig.flatErrors, suggestNames)
| DiagnosticStyle.Rich ->
diagnostic.FormatCore(tcConfig.flatErrors, suggestNames).Split([| '\n' |])
|> Array.map (fun msg -> "\n◦ " + msg)
|> String.Concat

let context =
match tcConfig.diagnosticStyle with
Expand All @@ -2201,14 +2199,14 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
|> System.IO.File.ReadAllLines

if m.StartLine = m.EndLine then
$"\n{m.StartLine} |{content[m.StartLine - 1]}\n"
+ $"""{String.init (m.StartColumn + 3) (fun _ -> " ")}^{String.init (m.EndColumn - m.StartColumn) (fun _ -> "~")}"""
$"\n {m.StartLine} | {content[m.StartLine - 1]}\n"
+ $"""{String.make (m.StartColumn + 6) ' '}{String.make (m.EndColumn - m.StartColumn) '^'}"""
|> Some
else
content
|> fun lines -> Array.sub lines (m.StartLine - 1) (m.EndLine - m.StartLine - 1)
|> Array.fold
(fun (context, lineNumber) line -> (context + $"\n{lineNumber} |{line}", lineNumber + 1))
(fun (context, lineNumber) line -> (context + $"\n{lineNumber} | {line}", lineNumber + 1))
("", (m.StartLine))
|> fst
|> Some
Expand All @@ -2220,6 +2218,7 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
Context = context
Canonical = canonical
Message = message
DiagnosticStyle = tcConfig.diagnosticStyle
}

errors.Add(FormattedDiagnostic.Long(severity, entry))
Expand Down Expand Up @@ -2247,16 +2246,33 @@ type PhasedDiagnostic with
match e with
| FormattedDiagnostic.Short(_, txt) -> buf.AppendString txt
| FormattedDiagnostic.Long(_, details) ->
match details.Location with
| Some l when not l.IsEmpty ->
buf.AppendString l.TextRepresentation
// Because details.Context depends on the value of details.Location, if details.Location is not None, details.Context can be accessed directly.
if details.Context.IsSome then
buf.AppendString details.Context.Value
| _ -> ()
match details.DiagnosticStyle with
| DiagnosticStyle.Emacs
| DiagnosticStyle.Gcc
| DiagnosticStyle.Test
| DiagnosticStyle.VisualStudio
| DiagnosticStyle.Default ->
match details.Location with
| Some l when not l.IsEmpty ->
buf.AppendString l.TextRepresentation

if details.Context.IsSome then
buf.AppendString details.Context.Value
| _ -> ()

buf.AppendString details.Canonical.TextRepresentation
buf.AppendString details.Message
| DiagnosticStyle.Rich ->
buf.AppendString details.Canonical.TextRepresentation
buf.AppendString details.Message

match details.Location with
| Some l when not l.IsEmpty ->
buf.AppendString l.TextRepresentation

buf.AppendString details.Canonical.TextRepresentation
buf.AppendString details.Message
if details.Context.IsSome then
buf.AppendString details.Context.Value
| _ -> ()

member diagnostic.OutputContext(buf, prefix, fileLineFunction) =
match diagnostic.Range with
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Driver/CompilerDiagnostics.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ type FormattedDiagnosticDetailedInfo =
{ Location: FormattedDiagnosticLocation option
Canonical: FormattedDiagnosticCanonicalInformation
Message: string
Context: string option }
Context: string option
DiagnosticStyle: DiagnosticStyle }

/// Used internally and in LegacyHostedCompilerForTesting
[<RequireQualifiedAccess>]
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Driver/CompilerOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ let testFlag tcConfigB =
let editorSpecificFlags (tcConfigB: TcConfigBuilder) =
[
CompilerOption("vserrors", tagNone, OptionUnit(fun () -> tcConfigB.diagnosticStyle <- DiagnosticStyle.VisualStudio), None, None)
CompilerOption("richerrors", tagNone, OptionUnit(fun () -> tcConfigB.diagnosticStyle <- DiagnosticStyle.Rich), None, None)
CompilerOption("validate-type-providers", tagNone, OptionUnit id, None, None) // preserved for compatibility's sake, no longer has any effect
CompilerOption("LCID", tagInt, OptionInt ignore, None, None)
CompilerOption("flaterrors", tagNone, OptionUnit(fun () -> tcConfigB.flatErrors <- true), None, None)
Expand Down
34 changes: 11 additions & 23 deletions src/Compiler/Service/SynPat.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ module SynPat =
else
ValueNone

/// Matches if any member in the given list is an inherit
/// or implementation of an interface with generic type args.
[<return: Struct>]
let (|AnyGenericInheritOrInterfaceImpl|_|) members =
if
members
|> List.exists (function
| SynMemberDefn.ImplicitInherit(inheritType = SynType.App(typeArgs = _ :: _))
| SynMemberDefn.ImplicitInherit(inheritType = SynType.LongIdentApp(typeArgs = _ :: _))
| SynMemberDefn.Interface(interfaceType = SynType.App(typeArgs = _ :: _))
| SynMemberDefn.Interface(interfaceType = SynType.LongIdentApp(typeArgs = _ :: _)) -> true
| _ -> false)
then
ValueSome AnyGenericInheritOrInterfaceImpl
else
ValueNone

/// Matches the rightmost potentially dangling nested pattern.
let rec (|Rightmost|) pat =
match pat with
Expand Down Expand Up @@ -182,15 +165,20 @@ module SynPat =
// type C<'T> = abstract M : 'T -> unit
// let _ = { new C<unit> with override _.M (()) = () }
// let _ = { new C<int * int> with override _.M ((x, y)) = () }
//
// Single versus double parens are also compiled differently in cases like these:
//
// type T =
// static member M () = () // .method public static void M()
// static member M (()) = () // .method public static void M(class [FSharp.Core]Microsoft.FSharp.Core.Unit _arg1)
// static member M (_ : int, _ : int) = () // .method public static void M(int32 _arg1, int32 _arg2)
// static member M ((_ : int, _ : int)) = () // .method public static void M(class [System.Runtime]System.Tuple`2<int32, int32> _arg1)
| SynPat.Paren((SynPat.Const(SynConst.Unit, _) | SynPat.Tuple(isStruct = false)), _),
SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynExpr(SynExpr.ObjExpr(
objType = SynType.App(typeArgs = _ :: _) | SynType.LongIdentApp(typeArgs = _ :: _))) :: _
SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: _
| SynPat.Tuple(isStruct = false),
SyntaxNode.SynPat(SynPat.Paren _) :: SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynExpr(SynExpr.ObjExpr(
objType = SynType.App(typeArgs = _ :: _) | SynType.LongIdentApp(typeArgs = _ :: _))) :: _
SyntaxNode.SynPat(SynPat.Paren _) :: SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: _
| SynPat.Paren((SynPat.Const(SynConst.Unit, _) | SynPat.Tuple(isStruct = false)), _),
SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynMemberDefn _ :: SyntaxNode.SynTypeDefn(SynTypeDefn(
typeRepr = SynTypeDefnRepr.ObjectModel(members = AnyGenericInheritOrInterfaceImpl))) :: _ -> true
SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynMemberDefn _ :: _ -> true

// Not required:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ let compileAValidScenario (scenario: Scenario) (method: Method) =
let cUnit =
let files =
scenario.Files
|> Array.map (fun (f: FileInScenario) -> SourceCodeFileKind.Create(f.FileWithAST.File, f.Content))
|> Array.toList
|> List.map (fun (f: FileInScenario) -> SourceCodeFileKind.Create(f.FileName, f.Content))

match files with
| [] -> failwith "empty files"
Expand All @@ -44,7 +43,7 @@ let compileAValidScenario (scenario: Scenario) (method: Method) =
|> shouldSucceed
|> ignore

let scenarios = codebases |> List.map (fun c -> [| box c |]) |> Array.ofList
let scenarios = scenarios |> List.map (fun c -> [| box c |])

[<Theory>]
[<MemberData(nameof scenarios)>]
Expand Down
Loading
Loading