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 src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ and SolveMemberConstraint (csenv: ConstraintSolverEnv) ignoreUnresolvedOverload
// We pretend for uniformity that the numeric types have a static property called Zero and One
// As with constants, only zero is polymorphic in its units
| [], [ty], false, "get_Zero", []
when IsNumericType g ty ->
when IsNumericType g ty || isCharTy g ty ->
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace rty ty
return TTraitBuiltIn

Expand Down
4 changes: 3 additions & 1 deletion src/fsharp/DotNetFrameworkDependencies.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
// Use the location of this dll
location

let inline ifEmptyUse alternative filename = if String.IsNullOrWhiteSpace filename then alternative else filename

let getFSharpCoreLibraryName = "FSharp.Core"
let getFsiLibraryName = "FSharp.Compiler.Interactive.Settings"
let getDefaultFSharpCoreLocation = Path.Combine(fSharpCompilerLocation, getFSharpCoreLibraryName + ".dll")
let getDefaultFsiLibraryLocation = Path.Combine(fSharpCompilerLocation, getFsiLibraryName + ".dll")
let implementationAssemblyDir = Path.GetDirectoryName(typeof<obj>.Assembly.Location)
let implementationAssemblyDir = Path.GetDirectoryName(typeof<obj>.Assembly.Location) |> ifEmptyUse fSharpCompilerLocation

// Use the ValueTuple that is executing with the compiler if it is from System.ValueTuple
// or the System.ValueTuple.dll that sits alongside the compiler. (Note we always ship one with the compiler)
Expand Down
6 changes: 4 additions & 2 deletions src/fsharp/FSharp.Core/prim-types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,7 @@ namespace Microsoft.FSharp.Core
elif aty.Equals(typeof<nativeint>) then unboxPrim<'T> (box 0n)
elif aty.Equals(typeof<byte>) then unboxPrim<'T> (box 0uy)
elif aty.Equals(typeof<uint16>) then unboxPrim<'T> (box 0us)
elif aty.Equals(typeof<char>) then unboxPrim<'T> (box '\000')
elif aty.Equals(typeof<uint32>) then unboxPrim<'T> (box 0u)
elif aty.Equals(typeof<uint64>) then unboxPrim<'T> (box 0UL)
elif aty.Equals(typeof<unativeint>) then unboxPrim<'T> (box 0un)
Expand All @@ -2392,7 +2393,7 @@ namespace Microsoft.FSharp.Core
elif aty.Equals(typeof<nativeint>) then unboxPrim<'T> (box 1n)
elif aty.Equals(typeof<byte>) then unboxPrim<'T> (box 1uy)
elif aty.Equals(typeof<uint16>) then unboxPrim<'T> (box 1us)
elif aty.Equals(typeof<char>) then unboxPrim<'T> (box (retype 1us : char))
elif aty.Equals(typeof<char>) then unboxPrim<'T> (box '\001')
elif aty.Equals(typeof<uint32>) then unboxPrim<'T> (box 1u)
elif aty.Equals(typeof<uint64>) then unboxPrim<'T> (box 1UL)
elif aty.Equals(typeof<unativeint>) then unboxPrim<'T> (box 1un)
Expand Down Expand Up @@ -2420,6 +2421,7 @@ namespace Microsoft.FSharp.Core
when ^T : unativeint = 0un
when ^T : int16 = 0s
when ^T : uint16 = 0us
when ^T : char = '\000'
when ^T : sbyte = 0y
when ^T : byte = 0uy
when ^T : decimal = 0M
Expand All @@ -2440,7 +2442,7 @@ namespace Microsoft.FSharp.Core
when ^T : unativeint = 1un
when ^T : int16 = 1s
when ^T : uint16 = 1us
when ^T : char = (retype 1us : char)
when ^T : char = '\001'
when ^T : sbyte = 1y
when ^T : byte = 1uy
when ^T : decimal = 1M
Expand Down
9 changes: 4 additions & 5 deletions src/utils/CompilerLocationUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ module internal FSharpEnvironment =
// Check for an app.config setting to redirect the default compiler location
// Like fsharp-compiler-location
try
// We let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions.
match Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN") with
| result when not (String.IsNullOrWhiteSpace result) -> Some result
|_->
// FSharp.Compiler support setting an appKey for compiler location. I've never seen this used.
let result = tryAppConfig "fsharp-compiler-location"
match result with
Expand All @@ -201,11 +205,6 @@ module internal FSharpEnvironment =
match probePoint with
| Some p when safeExists (Path.Combine(p,"FSharp.Core.dll")) -> Some p
| _ ->
// We let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions.
let result = Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN")
if not (String.IsNullOrEmpty(result)) then
Some result
else
// For the prototype compiler, we can just use the current domain
tryCurrentDomain()
with e -> None
Expand Down
4 changes: 3 additions & 1 deletion tests/fsharp/core/members/basics/test.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,7 @@ module ContraintTest = begin
open System.Numerics
let check s p = printf "Test %s: %s\n" s (if p then "pass" else "fail")
do check "d3oc001" (LanguagePrimitives.GenericZero<BigInteger> = 0I)
do check "d3oc002" (LanguagePrimitives.GenericZero<char> = '\000')
do check "d3oc003a" (LanguagePrimitives.GenericZero<int> = 0)
do check "d3oc003b" (LanguagePrimitives.GenericZero<unativeint> = 0un)
do check "d3oc003c" (LanguagePrimitives.GenericZero<uint64> = 0UL)
Expand All @@ -3051,7 +3052,8 @@ module ContraintTest = begin
do check "d3oc003k" (LanguagePrimitives.GenericZero<sbyte> = 0y)
do check "d3oc003l" (LanguagePrimitives.GenericZero<decimal> = 0M)

do check "d3oc001q" (LanguagePrimitives.GenericOne<BigInteger> = 1I)
do check "d3oc113q" (LanguagePrimitives.GenericOne<BigInteger> = 1I)
do check "d3oc113w" (LanguagePrimitives.GenericOne<char> = '\001')
do check "d3oc113e" (LanguagePrimitives.GenericOne<int> = 1)
do check "d3oc113r" (LanguagePrimitives.GenericOne<unativeint> = 1un)
do check "d3oc113t" (LanguagePrimitives.GenericOne<uint64> = 1UL)
Expand Down
58 changes: 29 additions & 29 deletions tests/fsharp/tools/eval/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -1193,35 +1193,35 @@ module EvaluationTests =

module InlinedOperationsStillDynamicallyAvailableTests =

checkEval "vroievr093" (<@ LanguagePrimitives.GenericZero<sbyte> @>) 0y
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<int16> @>) 0s
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<int32> @>) 0
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<int64> @>) 0L
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<nativeint> @>) 0n
checkEval "vroievr093" (<@ LanguagePrimitives.GenericZero<byte> @>) 0uy
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<uint16> @>) 0us
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<uint32> @>) 0u
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<uint64> @>) 0UL
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<unativeint> @>) 0un
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<float> @>) 0.0
checkEval "vroievr091" (<@ LanguagePrimitives.GenericZero<float32> @>) 0.0f
checkEval "vroievr092" (<@ LanguagePrimitives.GenericZero<decimal> @>) 0M



checkEval "vroievr093" (<@ LanguagePrimitives.GenericOne<sbyte> @>) 1y
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<int16> @>) 1s
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<int32> @>) 1
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<int64> @>) 1L
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<nativeint> @>) 1n
checkEval "vroievr193" (<@ LanguagePrimitives.GenericOne<byte> @>) 1uy
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<uint16> @>) 1us
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<uint32> @>) 1u
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<uint64> @>) 1UL
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<unativeint> @>) 1un
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<float> @>) 1.0
checkEval "vroievr191" (<@ LanguagePrimitives.GenericOne<float32> @>) 1.0f
checkEval "vroievr192" (<@ LanguagePrimitives.GenericOne<decimal> @>) 1M
checkEval "vroievr091a" (<@ LanguagePrimitives.GenericZero<char> @>) '\000'
checkEval "vroievr091b" (<@ LanguagePrimitives.GenericZero<sbyte> @>) 0y
checkEval "vroievr091c" (<@ LanguagePrimitives.GenericZero<int16> @>) 0s
checkEval "vroievr091d" (<@ LanguagePrimitives.GenericZero<int32> @>) 0
checkEval "vroievr091e" (<@ LanguagePrimitives.GenericZero<int64> @>) 0L
checkEval "vroievr091f" (<@ LanguagePrimitives.GenericZero<nativeint> @>) 0n
checkEval "vroievr091g" (<@ LanguagePrimitives.GenericZero<byte> @>) 0uy
checkEval "vroievr091h" (<@ LanguagePrimitives.GenericZero<uint16> @>) 0us
checkEval "vroievr091i" (<@ LanguagePrimitives.GenericZero<uint32> @>) 0u
checkEval "vroievr091j" (<@ LanguagePrimitives.GenericZero<uint64> @>) 0UL
checkEval "vroievr091k" (<@ LanguagePrimitives.GenericZero<unativeint> @>) 0un
checkEval "vroievr091l" (<@ LanguagePrimitives.GenericZero<float> @>) 0.0
checkEval "vroievr091m" (<@ LanguagePrimitives.GenericZero<float32> @>) 0.0f
checkEval "vroievr091n" (<@ LanguagePrimitives.GenericZero<decimal> @>) 0M

checkEval "vroievr092a" (<@ LanguagePrimitives.GenericOne<char> @>) '\001'
checkEval "vroievr092b" (<@ LanguagePrimitives.GenericOne<sbyte> @>) 1y
checkEval "vroievr092c" (<@ LanguagePrimitives.GenericOne<int16> @>) 1s
checkEval "vroievr092d" (<@ LanguagePrimitives.GenericOne<int32> @>) 1
checkEval "vroievr092e" (<@ LanguagePrimitives.GenericOne<int64> @>) 1L
checkEval "vroievr092f" (<@ LanguagePrimitives.GenericOne<nativeint> @>) 1n
checkEval "vroievr092g" (<@ LanguagePrimitives.GenericOne<byte> @>) 1uy
checkEval "vroievr092h" (<@ LanguagePrimitives.GenericOne<uint16> @>) 1us
checkEval "vroievr092i" (<@ LanguagePrimitives.GenericOne<uint32> @>) 1u
checkEval "vroievr092j" (<@ LanguagePrimitives.GenericOne<uint64> @>) 1UL
checkEval "vroievr092k" (<@ LanguagePrimitives.GenericOne<unativeint> @>) 1un
checkEval "vroievr092l" (<@ LanguagePrimitives.GenericOne<float> @>) 1.0
checkEval "vroievr092m" (<@ LanguagePrimitives.GenericOne<float32> @>) 1.0f
checkEval "vroievr092n" (<@ LanguagePrimitives.GenericOne<decimal> @>) 1M

check "vroievr0971" (LanguagePrimitives.AdditionDynamic 3y 4y) 7y
check "vroievr0972" (LanguagePrimitives.AdditionDynamic 3s 4s) 7s
Expand Down