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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
/tests/fcs/
/fcs/.paket/Paket.Restore.targets
msbuild.binlog
/fcs/FSharp.Compiler.Service.netstandard/*.fs
/fcs/FSharp.Compiler.Service.netstandard/*.fsi
4 changes: 2 additions & 2 deletions TESTGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ For the FSharpQA suite, the list of test areas and their associated "tags" is st

tests\fsharpqa\source\test.lst // FSharpQA suite

Tags are in the left column, paths to to corresponding test folders are in the right column. If no tags are specifie, all tests will be run.
Tags are in the left column, paths to to corresponding test folders are in the right column. If no tags are specified, all tests will be run.

If you want to re-run a particular test area, the easiest way to do so is to set a temporary tag for that area in test.lst (e.g. "RERUN") and then pass that as an argument to `build.cmd`: `build.cmd test-net40-fsharpqa include RERUN`.

Expand All @@ -65,7 +65,7 @@ These are all NUnit tests. You can execute these tests individually via the Visu
extension or the command line via `nunit3-console.exe`.

Note that for compatibility reasons, the IDE unit tests should be run in a 32-bit process,
using the '--x86' flag to `nunit3-console.exe`
using the `--x86` flag to `nunit3-console.exe`



Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<DefineConstants>$(DefineConstants);DOTNETCORE;FX_ATLEAST_45;FX_ATLEAST_PORTABLE;FX_NO_RUNTIMEENVIRONMENT;FX_RESHAPED_REFLECTION;TODO_REWORK_ASSEMBLY_LOAD;</DefineConstants>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DefineConstants>$(DefineConstants);DOTNETCORE</DefineConstants>
<DefineConstants>$(DefineConstants);FX_ATLEAST_45</DefineConstants>
<DefineConstants>$(DefineConstants);FX_ATLEAST_PORTABLE</DefineConstants>
<DefineConstants>$(DefineConstants);FX_NO_RUNTIMEENVIRONMENT</DefineConstants>
<DefineConstants>$(DefineConstants);FX_RESHAPED_REFLECTION</DefineConstants>
<DefineConstants>$(DefineConstants);NO_EXTENSIONTYPING</DefineConstants>
<DefineConstants>$(DefineConstants);TODO_REWORK_ASSEMBLY_LOAD</DefineConstants>
<NoWarn>$(NoWarn);44;</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DelaySign>true</DelaySign>
Expand Down Expand Up @@ -36,25 +42,21 @@
<!--<Compile Include="../service/ProjectAnalysisTests.fs">
<Link>ProjectAnalysisTests.fs</Link>
</Compile>-->
<Compile Include="../../tests/service/Program.fs">
<Link>Program.fs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="NUnitLite" Version="3.6.1" />
<PackageReference Include="NUnit" Version="3.6.1" />
<PackageReference Include="FSharp.Core" Version="4.1.*" PrivateAssets="All" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.4.1" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="Dotnet.ProjInfo" Version="0.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="Dotnet.ProjInfo" Version="0.9.0" />
</ItemGroup>
<Target Name="PrecompileScript" BeforeTargets="BeforeBuild">
<Exec Command="dotnet restore &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6/Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj&quot;" />
<Exec Command="dotnet build &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6/Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj&quot;" />
<Exec Command="dotnet restore &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj&quot;" />
<Exec Command="dotnet build &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj&quot;" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<Compile Include="$(FSharpSourcesRoot)\..\tests\service\EditorTests.fs">
<Link>EditorTests.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)\..\tests\service\Symbols.fs">
<Link>Symbols.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)\..\tests\service\FileSystemTests.fs">
<Link>FileSystemTests.fs</Link>
</Compile>
Expand Down
58 changes: 24 additions & 34 deletions src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ let ShowAccessDomain ad =
// Solve

exception NonRigidTypar of DisplayEnv * string option * range * TType * TType * range
exception LocallyAbortOperationThatFailsToResolveOverload
exception LocallyAbortOperationThatLosesAbbrevs
let localAbortD = ErrorD LocallyAbortOperationThatLosesAbbrevs

Expand Down Expand Up @@ -739,19 +738,19 @@ and solveTypMeetsTyparConstraints (csenv:ConstraintSolverEnv) ndeep m2 trace ty
| Some destTypar ->
AddConstraint csenv ndeep m2 trace destTypar (TyparConstraint.DefaultsTo(priority, dty, m))

| TyparConstraint.SupportsNull m2 -> SolveTypSupportsNull csenv ndeep m2 trace ty
| TyparConstraint.IsEnum(underlying, m2) -> SolveTypIsEnum csenv ndeep m2 trace ty underlying
| TyparConstraint.SupportsComparison(m2) -> SolveTypeSupportsComparison csenv ndeep m2 trace ty
| TyparConstraint.SupportsEquality(m2) -> SolveTypSupportsEquality csenv ndeep m2 trace ty
| TyparConstraint.SupportsNull m2 -> SolveTypSupportsNull csenv ndeep m2 trace ty
| TyparConstraint.IsEnum(underlying, m2) -> SolveTypIsEnum csenv ndeep m2 trace ty underlying
| TyparConstraint.SupportsComparison(m2) -> SolveTypeSupportsComparison csenv ndeep m2 trace ty
| TyparConstraint.SupportsEquality(m2) -> SolveTypSupportsEquality csenv ndeep m2 trace ty
| TyparConstraint.IsDelegate(aty, bty, m2) -> SolveTypIsDelegate csenv ndeep m2 trace ty aty bty
| TyparConstraint.IsNonNullableStruct m2 -> SolveTypIsNonNullableValueType csenv ndeep m2 trace ty
| TyparConstraint.IsUnmanaged m2 -> SolveTypIsUnmanaged csenv ndeep m2 trace ty
| TyparConstraint.IsReferenceType m2 -> SolveTypIsReferenceType csenv ndeep m2 trace ty
| TyparConstraint.RequiresDefaultConstructor m2 -> SolveTypRequiresDefaultConstructor csenv ndeep m2 trace ty
| TyparConstraint.IsNonNullableStruct m2 -> SolveTypIsNonNullableValueType csenv ndeep m2 trace ty
| TyparConstraint.IsUnmanaged m2 -> SolveTypIsUnmanaged csenv ndeep m2 trace ty
| TyparConstraint.IsReferenceType m2 -> SolveTypIsReferenceType csenv ndeep m2 trace ty
| TyparConstraint.RequiresDefaultConstructor m2 -> SolveTypRequiresDefaultConstructor csenv ndeep m2 trace ty
| TyparConstraint.SimpleChoice(tys, m2) -> SolveTypChoice csenv ndeep m2 trace ty tys
| TyparConstraint.CoercesTo(ty2, m2) -> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m2 trace None ty2 ty
| TyparConstraint.MayResolveMember(traitInfo, m2) ->
SolveMemberConstraint csenv false false ndeep m2 trace traitInfo ++ (fun _ -> CompleteD)
| TyparConstraint.MayResolveMember(traitInfo, m2) ->
SolveMemberConstraint csenv false ndeep m2 trace traitInfo ++ (fun _ -> CompleteD)
)))


Expand All @@ -761,15 +760,14 @@ and SolveTypEqualsTyp (csenv:ConstraintSolverEnv) ndeep m2 (trace: OptionalTrace
let ndeep = ndeep + 1
let aenv = csenv.EquivEnv
let g = csenv.g
if ty1 === ty2 then CompleteD else

match cxsln with
| Some (traitInfo, traitSln) when traitInfo.Solution.IsNone ->
// If this is an overload resolution at this point it's safe to assume the candidate member being evaluated solves this member constraint.
TransactMemberConstraintSolution traitInfo trace traitSln
| _ -> ()

if ty1 === ty2 then CompleteD else

let canShortcut = not trace.HasTrace
let sty1 = stripTyEqnsA csenv.g canShortcut ty1
let sty2 = stripTyEqnsA csenv.g canShortcut ty2
Expand Down Expand Up @@ -943,7 +941,7 @@ and SolveDimensionlessNumericType (csenv:ConstraintSolverEnv) ndeep m2 trace ty
/// We pretend int and other types support a number of operators. In the actual IL for mscorlib they
/// don't, however the type-directed static optimization rules in the library code that makes use of this
/// will deal with the problem.
and SolveMemberConstraint (csenv:ConstraintSolverEnv) ignoreUnresolvedOverload permitWeakResolution ndeep m2 trace (TTrait(tys, nm, memFlags, argtys, rty, sln)): OperationResult<bool> =
and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep m2 trace (TTrait(tys,nm,memFlags,argtys,rty,sln)) : OperationResult<bool> =
// Do not re-solve if already solved
if sln.Value.IsSome then ResultD true else
let g = csenv.g
Expand Down Expand Up @@ -1300,12 +1298,9 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) ignoreUnresolvedOverload p
let frees = GetFreeTyparsOfMemberConstraint csenv traitInfo

// If there's nothing left to learn then raise the errors
(if (permitWeakResolution && isNil support) || isNil frees then errors
// Otherwise re-record the trait waiting for canonicalization
else AddMemberConstraint csenv ndeep m2 trace traitInfo support frees) ++ (fun () ->
match errors with
| ErrorResult (_, UnresolvedOverloading _) when not ignoreUnresolvedOverload && (not (nm = "op_Explicit" || nm = "op_Implicit")) -> ErrorD LocallyAbortOperationThatFailsToResolveOverload
| _ -> ResultD TTraitUnsolved)
(if (permitWeakResolution && isNil support) || isNil frees then errors
// Otherwise re-record the trait waiting for canonicalization
else AddMemberConstraint csenv ndeep m2 trace traitInfo support frees) ++ (fun () -> ResultD TTraitUnsolved)
)
++
(fun res -> RecordMemberConstraintSolution csenv.SolverState m trace traitInfo res))
Expand Down Expand Up @@ -1447,7 +1442,7 @@ and SolveRelevantMemberConstraintsForTypar (csenv:ConstraintSolverEnv) ndeep per
cxs
|> AtLeastOneD (fun (traitInfo, m2) ->
let csenv = { csenv with m = m2 }
SolveMemberConstraint csenv true permitWeakResolution (ndeep+1) m2 trace traitInfo)
SolveMemberConstraint csenv permitWeakResolution (ndeep+1) m2 trace traitInfo)

and CanonicalizeRelevantMemberConstraints (csenv:ConstraintSolverEnv) ndeep trace tps =
SolveRelevantMemberConstraints csenv ndeep true trace tps
Expand Down Expand Up @@ -1962,22 +1957,18 @@ and CanMemberSigsMatchUpToCheck
// to allow us to report the outer types involved in the constraint
and private SolveTypSubsumesTypWithReport (csenv:ConstraintSolverEnv) ndeep m trace cxsln ty1 ty2 =
TryD (fun () -> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m trace cxsln ty1 ty2)
(function
| LocallyAbortOperationThatFailsToResolveOverload -> CompleteD
| res ->
match csenv.eContextInfo with
| ContextInfo.RuntimeTypeTest isOperator ->
// test if we can cast other way around
(fun res ->
match csenv.eContextInfo with
| ContextInfo.RuntimeTypeTest isOperator ->
// test if we can cast other way around
match CollectThenUndo (fun newTrace -> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m (OptionalTrace.WithTrace newTrace) cxsln ty2 ty1) with
| OkResult _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g, csenv.DisplayEnv, ty1, ty2, res, ContextInfo.DowncastUsedInsteadOfUpcast isOperator, m))
| _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g, csenv.DisplayEnv, ty1, ty2, res, ContextInfo.NoContext, m))
| _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g, csenv.DisplayEnv, ty1, ty2, res, csenv.eContextInfo, m)))

and private SolveTypEqualsTypWithReport (csenv:ConstraintSolverEnv) ndeep m trace cxsln ty1 ty2 =
TryD (fun () -> SolveTypEqualsTypKeepAbbrevsWithCxsln csenv ndeep m trace cxsln ty1 ty2)
(function
| LocallyAbortOperationThatFailsToResolveOverload -> CompleteD
| res -> ErrorD (ErrorFromAddingTypeEquation(csenv.g, csenv.DisplayEnv, ty1, ty2, res, m)))
(fun res -> ErrorD (ErrorFromAddingTypeEquation(csenv.g, csenv.DisplayEnv, ty1, ty2, res, m)))

and ArgsMustSubsumeOrConvert
(csenv:ConstraintSolverEnv)
Expand Down Expand Up @@ -2543,7 +2534,7 @@ let AddCxTypeMustSubsumeType contextInfo denv css m trace ty1 ty2 =
|> RaiseOperationResult

let AddCxMethodConstraint denv css m trace traitInfo =
TryD (fun () -> SolveMemberConstraint (MakeConstraintSolverEnv ContextInfo.NoContext css m denv) true false 0 m trace traitInfo ++ (fun _ -> CompleteD))
TryD (fun () -> SolveMemberConstraint (MakeConstraintSolverEnv ContextInfo.NoContext css m denv) false 0 m trace traitInfo ++ (fun _ -> CompleteD))
(fun res -> ErrorD (ErrorFromAddingConstraint(denv, res, m)))
|> RaiseOperationResult

Expand Down Expand Up @@ -2601,7 +2592,7 @@ let CodegenWitnessThatTypSupportsTraitConstraint tcVal g amap m (traitInfo:Trait
InfoReader = new InfoReader(g, amap) }

let csenv = MakeConstraintSolverEnv ContextInfo.NoContext css m (DisplayEnv.Empty g)
SolveMemberConstraint csenv true true 0 m NoTrace traitInfo ++ (fun _res ->
SolveMemberConstraint csenv true 0 m NoTrace traitInfo ++ (fun _res ->
let sln =
match traitInfo.Solution with
| None -> Choice4Of4()
Expand Down Expand Up @@ -2725,5 +2716,4 @@ let IsApplicableMethApprox g amap m (minfo:MethInfo) availObjTy =
|> CommitOperationResult
| _ -> true
else
true

true
1 change: 0 additions & 1 deletion src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ FieldNotContainedMutablesDiffer,"The module contains the field\n %s \nbut
FieldNotContainedLiteralsDiffer,"The module contains the field\n %s \nbut its signature specifies\n %s \nThe 'literal' modifiers differ"
FieldNotContainedTypesDiffer,"The module contains the field\n %s \nbut its signature specifies\n %s \nThe types differ"
331,typrelCannotResolveImplicitGenericInstantiation,"The implicit instantiation of a generic construct at or near this point could not be resolved because it could resolve to multiple unrelated types, e.g. '%s' and '%s'. Consider using type annotations to resolve the ambiguity"
332,typrelCannotResolveAmbiguityInOverloadedOperator,"Could not resolve the ambiguity inherent in the use of the operator '%s' at or near this program point. Consider using type annotations to resolve the ambiguity."
333,typrelCannotResolveAmbiguityInPrintf,"Could not resolve the ambiguity inherent in the use of a 'printf'-style format string"
334,typrelCannotResolveAmbiguityInEnum,"Could not resolve the ambiguity in the use of a generic construct with an 'enum' constraint at or near this position"
335,typrelCannotResolveAmbiguityInDelegate,"Could not resolve the ambiguity in the use of a generic construct with a 'delegate' constraint at or near this position"
Expand Down
10 changes: 7 additions & 3 deletions src/fsharp/FSharp.Build/WriteCodeFragment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,19 @@ open System.Reflection"
let sb = StringBuilder().AppendLine(boilerplate).AppendLine()
let code = Array.fold (fun (sb:StringBuilder) (item:ITaskItem) -> sb.AppendLine(WriteCodeFragment.GenerateAttribute item)) sb _assemblyAttributes
code.AppendLine().AppendLine("do()") |> ignore
let fileName = _outputFile.ItemSpec
let outputFileItem =
if not (isNull _outputFile) && not (isNull _outputDirectory) && not (Path.IsPathRooted(_outputFile.ItemSpec)) then
TaskItem(Path.Combine(_outputDirectory.ItemSpec, _outputFile.ItemSpec)) :> ITaskItem
if not (isNull _outputFile) && not (isNull _outputDirectory) && not (Path.IsPathRooted(fileName)) then
TaskItem(Path.Combine(_outputDirectory.ItemSpec, fileName)) :> ITaskItem
elif isNull _outputFile then
let tempFile = Path.Combine(Path.GetTempPath(), sprintf "tmp%s.fs" (Guid.NewGuid().ToString("N")))
TaskItem(tempFile) :> ITaskItem
else
_outputFile
File.WriteAllText(_outputFile.ItemSpec, code.ToString())
let codeText = code.ToString()
let alreadyExists = (try File.Exists fileName && File.ReadAllText(fileName) = codeText with _ -> false)
if not alreadyExists then
File.WriteAllText(fileName, codeText)
_outputFile <- outputFileItem
true
with e ->
Expand Down
Loading