зеркало из https://github.com/dotnet/fsharp.git
add more tests for SRTP variations (#8435)
* add more tests for SRTP variations * teak names of tests * fix baseline
This commit is contained in:
Родитель
de0637f902
Коммит
7f14ea0d7f
|
@ -2167,6 +2167,12 @@ module TypecheckTests =
|
|||
fsc cfg "%s --target:library -o:pos34.dll --warnaserror" cfg.fsc_flags ["pos34.fs"]
|
||||
peverify cfg "pos34.dll"
|
||||
|
||||
[<Test>]
|
||||
let ``sigs pos35`` () =
|
||||
let cfg = testConfig "typecheck/sigs"
|
||||
fsc cfg "%s --target:library -o:pos35.dll --warnaserror" cfg.fsc_flags ["pos35.fs"]
|
||||
peverify cfg "pos35.dll"
|
||||
|
||||
[<Test>]
|
||||
let ``sigs pos23`` () =
|
||||
let cfg = testConfig "typecheck/sigs"
|
||||
|
@ -2687,6 +2693,27 @@ module TypecheckTests =
|
|||
[<Test>]
|
||||
let ``type check neg122`` () = singleNegTest (testConfig "typecheck/sigs") "neg122"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg123`` () = singleNegTest (testConfig "typecheck/sigs") "neg123"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg124`` () = singleNegTest (testConfig "typecheck/sigs") "neg124"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg125`` () = singleNegTest (testConfig "typecheck/sigs") "neg125"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg126`` () = singleNegTest (testConfig "typecheck/sigs") "neg126"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg127`` () = singleNegTest (testConfig "typecheck/sigs") "neg127"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg128`` () = singleNegTest (testConfig "typecheck/sigs") "neg128"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg129`` () = singleNegTest (testConfig "typecheck/sigs") "neg129"
|
||||
|
||||
[<Test>]
|
||||
let ``type check neg_anon_1`` () = singleNegTest (testConfig "typecheck/sigs") "neg_anon_1"
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
neg123.fs(19,18,19,27): typecheck error FS0003: This value is not a function and cannot be applied.
|
|
@ -1,6 +1,5 @@
|
|||
// #Conformance #DeclarationElements #MemberDefinitions #Overloading
|
||||
// https://github.com/Microsoft/visualfsharp/issues/351 - slow overlaod resolution
|
||||
//<Expects id="FS0003" status="error">This value is not a function and cannot be applied</Expects>
|
||||
module Neg123
|
||||
|
||||
type Switcher = Switcher
|
||||
|
||||
let inline checker< ^s, ^r when (^s or ^r) : (static member pass : ^r -> unit)> (s : ^s) (r : ^r) = ()
|
||||
|
@ -17,9 +16,4 @@ type Switcher with
|
|||
static member inline pass(_ : unit) = ()
|
||||
static member inline pass(_ : int) = ()
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
let res : unit = format () "text" 5 "more text" ()
|
||||
printfn "%A" res
|
||||
System.Console.ReadKey()
|
||||
0 // return an integer exit code
|
||||
let res : unit = format () "text" 5 "more text" ()
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Type constraint mismatch when applying the default type 'obj' for a type inference variable. No overloads match for method 'unsigned_witness'. The available overloads are shown below. Consider adding further type constraints
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:uint64 -> uint64'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'uint64'
|
||||
.
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:int64 -> uint64'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'int64'
|
||||
.
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:uint32 -> uint32'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'uint32'
|
||||
.
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:int32 -> uint32'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'int32'
|
||||
.
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:uint16 -> uint16'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'uint16'
|
||||
.
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:int16 -> uint16'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'int16'
|
||||
.
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:byte -> byte'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'byte'
|
||||
.
|
||||
neg124.fs(39,27,39,35): typecheck error FS0071: Possible overload: 'static member Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector.witnesses.unsigned_witness : x:sbyte -> uint8'. Type constraint mismatch. The type
|
||||
'obj'
|
||||
is not compatible with type
|
||||
'sbyte'
|
||||
.
|
|
@ -0,0 +1,40 @@
|
|||
module Neg124
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
module Negative_SelectOverloadedWitnessBasedOnInputAndReturnTypeWithoutOutputTypeSelector =
|
||||
type witnesses =
|
||||
static member inline unsigned_witness (x : sbyte) = uint8 x
|
||||
static member inline unsigned_witness (x : byte) = x
|
||||
static member inline unsigned_witness (x : int16) = uint16 x
|
||||
static member inline unsigned_witness (x : uint16) = x
|
||||
static member inline unsigned_witness (x : int32) = uint32 x
|
||||
static member inline unsigned_witness (x : uint32) = x
|
||||
static member inline unsigned_witness (x : int64) = uint64 x
|
||||
static member inline unsigned_witness (x : uint64) = x
|
||||
|
||||
// Note, this doesn't try to use the output to select
|
||||
let inline call_unsigned_witness< ^witnesses, ^input, ^output when (^witnesses or ^input) : (static member unsigned_witness : ^input -> ^output)> (x : ^input) =
|
||||
((^witnesses or ^input) : (static member unsigned_witness : ^input -> ^output) x)
|
||||
|
||||
// unsigned: ^a -> ^b
|
||||
let inline unsigned num = call_unsigned_witness<witnesses, _, _> num
|
||||
|
||||
// Positive cases
|
||||
let v1 = unsigned 0y
|
||||
let v2 = unsigned 0s
|
||||
let v3 = unsigned 0
|
||||
let v4 = unsigned 0L
|
||||
|
||||
let f1 : int8 -> uint8 = unsigned
|
||||
let f2 : int16 -> uint16 = unsigned
|
||||
let f3 : int32 -> uint32 = unsigned
|
||||
let f4 : int64 -> uint64 = unsigned
|
||||
|
||||
let g1 : int8 -> _ = unsigned
|
||||
let g2 : int16 -> _ = unsigned
|
||||
let g3 : int32 -> _ = unsigned
|
||||
let g4 : int64 -> _ = unsigned
|
||||
|
||||
// Negative case - not enough information here
|
||||
let h1 : _ -> uint8 = unsigned
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
neg125.fs(39,30,39,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(40,30,40,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(41,31,41,33): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(42,30,42,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(43,30,43,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(44,30,44,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(45,29,45,31): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(46,31,46,33): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(47,31,47,33): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(48,32,48,34): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(49,33,49,35): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(50,33,50,35): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg125.fs(51,33,51,35): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
|
@ -0,0 +1,51 @@
|
|||
module Neg125
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
//
|
||||
// See also pos35.fs
|
||||
//
|
||||
// This removes ^output as a type selector for the witness, and no longer passes a dummy ^output
|
||||
//
|
||||
// This means that when both ^witnesses and ^input are known, the overload determining the ^output still can't be determined,
|
||||
// and overload resolutiuon failures are reported
|
||||
module Negative_SelectOverloadedWitnessBasedOnReturnTypeWithoutOutputTypeSelectAndWithoutPassingDummyArgument =
|
||||
open System
|
||||
open System.Numerics
|
||||
let _uint8max = bigint (uint32 Byte.MaxValue)
|
||||
let _uint16max = bigint (uint32 UInt16.MaxValue)
|
||||
let _uint32max = bigint UInt32.MaxValue
|
||||
let _uint64max = bigint UInt64.MaxValue
|
||||
type witnesses =
|
||||
static member inline convert_witness (x : bigint) = int (uint32 (x &&& _uint32max))
|
||||
static member inline convert_witness (x : bigint) = int64 (uint64 (x &&& _uint64max))
|
||||
static member inline convert_witness (x : bigint) = x
|
||||
static member inline convert_witness (x : bigint) = float x
|
||||
static member inline convert_witness (x : bigint) = sbyte (byte (x &&& _uint8max))
|
||||
static member inline convert_witness (x : bigint) = int16 (uint16 (x &&& _uint16max))
|
||||
static member inline convert_witness (x : bigint) = byte (x &&& _uint8max)
|
||||
static member inline convert_witness (x : bigint) = uint16 (x &&& _uint16max)
|
||||
static member inline convert_witness (x : bigint) = uint32 (x &&& _uint32max)
|
||||
static member inline convert_witness (x : bigint) = uint64 (x &&& _uint64max)
|
||||
static member inline convert_witness (x : bigint) = float32 x
|
||||
static member inline convert_witness (x : bigint) = decimal x
|
||||
static member inline convert_witness (x : bigint) = Complex(float x, 0.0)
|
||||
// Note ^output in the list of "or" types
|
||||
let inline call_convert_witness< ^witnesses, ^input, ^output when (^witnesses or ^input) : (static member convert_witness : ^input -> ^output)> (b : ^input) =
|
||||
((^witnesses or ^input) : (static member convert_witness : ^input -> ^output) (b))
|
||||
|
||||
let inline convert num =
|
||||
call_convert_witness<witnesses, _, _> (num)
|
||||
|
||||
let v1 : int32 = convert 0I
|
||||
let v2 : int64 = convert 0I
|
||||
let v3 : bigint = convert 0I
|
||||
let v4 : float = convert 0I
|
||||
let v5 : sbyte = convert 0I
|
||||
let v6 : int16 = convert 0I
|
||||
let v7 : byte = convert 0I
|
||||
let v8 : uint16 = convert 0I
|
||||
let v9 : uint32 = convert 0I
|
||||
let v10 : uint64 = convert 0I
|
||||
let v11 : float32 = convert 0I
|
||||
let v12 : decimal = convert 0I
|
||||
let v13 : Complex = convert 0I
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
neg126.fs(30,32,30,48): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type 'sbyte'.
|
|
@ -0,0 +1,32 @@
|
|||
module Neg126
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
//
|
||||
// Here we are attempting to select a witness based on input type.
|
||||
//
|
||||
// However, only one witness is present.
|
||||
//
|
||||
// Due to the problem described in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580396911,
|
||||
// "generic inline code we apply weak resolution to constraints that could otherwise be generalised",
|
||||
// this generates a warning because overload resolution is invoked and the input type of "foo" becomes "sbyte"
|
||||
//
|
||||
// The inferred type should ideally be
|
||||
// foo: ^a -> ^b
|
||||
// but is actually
|
||||
// foo: sbyte -> byte
|
||||
//
|
||||
// That is, the code is not generic at all, because the F# compiler thinks that it commit to the one and only witness.
|
||||
//
|
||||
// This test exists to pin down that we get a warning produced saying ^a has been instantiated to "sbyte"
|
||||
|
||||
module Negative_SelectOverloadedWitnessBasedOnInputTypeOneWitness =
|
||||
type witnesses =
|
||||
static member inline foo_witness (x : sbyte) : byte = byte x
|
||||
|
||||
// Note, this doesn't try to use the output to select
|
||||
let inline call_foo_witness< ^witnesses, ^input, ^output when (^witnesses or ^input) : (static member foo_witness : ^input -> ^output)> (x : ^input) =
|
||||
((^witnesses or ^input) : (static member foo_witness : ^input -> ^output) x)
|
||||
|
||||
let inline foo (num: ^a) = call_foo_witness<witnesses, _, _> num
|
||||
let v1 = foo 0y
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
neg127.fs(47,30,47,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(48,30,48,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(49,31,49,33): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(50,30,50,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(51,30,51,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(52,30,52,32): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(53,29,53,31): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(54,31,54,33): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(55,31,55,33): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(56,32,56,34): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(57,33,57,35): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(58,33,58,35): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
||||
|
||||
neg127.fs(59,33,59,35): typecheck error FS0001: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint -> Complex, static member witnesses.convert_witness : x:bigint -> bigint, static member witnesses.convert_witness : x:bigint -> byte, static member witnesses.convert_witness : x:bigint -> decimal, static member witnesses.convert_witness : x:bigint -> float, static member witnesses.convert_witness : x:bigint -> float32, static member witnesses.convert_witness : x:bigint -> int, static member witnesses.convert_witness : x:bigint -> int16, static member witnesses.convert_witness : x:bigint -> int64, static member witnesses.convert_witness : x:bigint -> sbyte, static member witnesses.convert_witness : x:bigint -> uint16, static member witnesses.convert_witness : x:bigint -> uint32, static member witnesses.convert_witness : x:bigint -> uint64
|
|
@ -0,0 +1,59 @@
|
|||
module Neg127
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
//
|
||||
// See also pos35.fs, neg125.fs
|
||||
//
|
||||
// This no longer passes a dummy ^output but keeps ^output as a witness selector
|
||||
//
|
||||
// When both ^witnesses and ^input are known, the overload determining the ^output still can't be determined.
|
||||
// However overload resolution is **not** delayed because the language rule is that overload resolution
|
||||
// goes ahead once the support in the **argument** types of the constraint have all been resolved.
|
||||
//
|
||||
// This design decision for SRTP resolution was based on the (technically false but normally true) assumption that
|
||||
// overload resolution will not depend on return type.
|
||||
//
|
||||
// The workaround for this in SRTP generic code is to pass a dummy Unchecked.defaultof<_> argument of the type of the
|
||||
// return type.
|
||||
|
||||
module Negative_SelectOverloadedWitnessBasedOnReturnTypeWithoutPassingDummyArgument =
|
||||
open System
|
||||
open System.Numerics
|
||||
let _uint8max = bigint (uint32 Byte.MaxValue)
|
||||
let _uint16max = bigint (uint32 UInt16.MaxValue)
|
||||
let _uint32max = bigint UInt32.MaxValue
|
||||
let _uint64max = bigint UInt64.MaxValue
|
||||
type witnesses =
|
||||
static member inline convert_witness (x : bigint) = int (uint32 (x &&& _uint32max))
|
||||
static member inline convert_witness (x : bigint) = int64 (uint64 (x &&& _uint64max))
|
||||
static member inline convert_witness (x : bigint) = x
|
||||
static member inline convert_witness (x : bigint) = float x
|
||||
static member inline convert_witness (x : bigint) = sbyte (byte (x &&& _uint8max))
|
||||
static member inline convert_witness (x : bigint) = int16 (uint16 (x &&& _uint16max))
|
||||
static member inline convert_witness (x : bigint) = byte (x &&& _uint8max)
|
||||
static member inline convert_witness (x : bigint) = uint16 (x &&& _uint16max)
|
||||
static member inline convert_witness (x : bigint) = uint32 (x &&& _uint32max)
|
||||
static member inline convert_witness (x : bigint) = uint64 (x &&& _uint64max)
|
||||
static member inline convert_witness (x : bigint) = float32 x
|
||||
static member inline convert_witness (x : bigint) = decimal x
|
||||
static member inline convert_witness (x : bigint) = Complex(float x, 0.0)
|
||||
|
||||
let inline call_convert_witness< ^witnesses, ^input, ^output when (^witnesses or ^input or ^output) : (static member convert_witness : ^input -> ^output)> (b : ^input) =
|
||||
((^witnesses or ^input or ^output) : (static member convert_witness : ^input -> ^output) (b))
|
||||
|
||||
let inline convert num =
|
||||
call_convert_witness<witnesses, _, _> (num)
|
||||
// These all cause errors
|
||||
let v1 : int32 = convert 0I
|
||||
let v2 : int64 = convert 0I
|
||||
let v3 : bigint = convert 0I
|
||||
let v4 : float = convert 0I
|
||||
let v5 : sbyte = convert 0I
|
||||
let v6 : int16 = convert 0I
|
||||
let v7 : byte = convert 0I
|
||||
let v8 : uint16 = convert 0I
|
||||
let v9 : uint32 = convert 0I
|
||||
let v10 : uint64 = convert 0I
|
||||
let v11 : float32 = convert 0I
|
||||
let v12 : decimal = convert 0I
|
||||
let v13 : Complex = convert 0I
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
neg128.fs(36,47,36,54): typecheck error FS0043: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint * _output:Complex -> Complex, static member witnesses.convert_witness : x:bigint * _output:bigint -> bigint, static member witnesses.convert_witness : x:bigint * _output:byte -> byte, static member witnesses.convert_witness : x:bigint * _output:decimal -> decimal, static member witnesses.convert_witness : x:bigint * _output:float -> float, static member witnesses.convert_witness : x:bigint * _output:float32 -> float32, static member witnesses.convert_witness : x:bigint * _output:int16 -> int16, static member witnesses.convert_witness : x:bigint * _output:int32 -> int, static member witnesses.convert_witness : x:bigint * _output:int64 -> int64, static member witnesses.convert_witness : x:bigint * _output:sbyte -> sbyte, static member witnesses.convert_witness : x:bigint * _output:uint16 -> uint16, static member witnesses.convert_witness : x:bigint * _output:uint32 -> uint32, static member witnesses.convert_witness : x:bigint * _output:uint64 -> uint64
|
|
@ -0,0 +1,36 @@
|
|||
module Neg128
|
||||
|
||||
module Negative_SelectOverloadedWitnessBasedOnReturnTypeByPassingDummyArgumentGenericOutputSelector =
|
||||
open System
|
||||
open System.Numerics
|
||||
let _uint8max = bigint (uint32 Byte.MaxValue)
|
||||
let _uint16max = bigint (uint32 UInt16.MaxValue)
|
||||
let _uint32max = bigint UInt32.MaxValue
|
||||
let _uint64max = bigint UInt64.MaxValue
|
||||
type witnesses =
|
||||
static member inline convert_witness (x : bigint, _output : int32) = int (uint32 (x &&& _uint32max))
|
||||
static member inline convert_witness (x : bigint, _output : int64) = int64 (uint64 (x &&& _uint64max))
|
||||
static member inline convert_witness (x : bigint, _output : bigint) = x
|
||||
static member inline convert_witness (x : bigint, _output : float) = float x
|
||||
static member inline convert_witness (x : bigint, _output : sbyte) = sbyte (byte (x &&& _uint8max))
|
||||
static member inline convert_witness (x : bigint, _output : int16) = int16 (uint16 (x &&& _uint16max))
|
||||
static member inline convert_witness (x : bigint, _output : byte) = byte (x &&& _uint8max)
|
||||
static member inline convert_witness (x : bigint, _output : uint16) = uint16 (x &&& _uint16max)
|
||||
static member inline convert_witness (x : bigint, _output : uint32) = uint32 (x &&& _uint32max)
|
||||
static member inline convert_witness (x : bigint, _output : uint64) = uint64 (x &&& _uint64max)
|
||||
static member inline convert_witness (x : bigint, _output : float32) = float32 x
|
||||
static member inline convert_witness (x : bigint, _output : decimal) = decimal x
|
||||
static member inline convert_witness (x : bigint, _output : Complex) = Complex(float x, 0.0)
|
||||
|
||||
let inline call_convert_witness< ^witnesses, ^input, 'output when (^witnesses or ^input) : (static member convert_witness : ^input * 'output -> 'output)> (b : ^input, c : 'output) =
|
||||
((^witnesses or ^input) : (static member convert_witness : ^input * 'output -> 'output) (b, c))
|
||||
|
||||
let inline convert num : 'output =
|
||||
call_convert_witness<witnesses, _, _> (num, Unchecked.defaultof<'output>)
|
||||
|
||||
// These solve ok
|
||||
let v1 : int32 = convert 777I
|
||||
let v2 : int64 = convert 777I
|
||||
|
||||
// This gives an error, because solving kicks in once all selector types are known
|
||||
let inline inst (num: bigint) : 'output = convert num
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
neg129.fs(67,47,67,54): typecheck error FS0043: A unique overload for method 'convert_witness' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member witnesses.convert_witness : x:bigint * _output:Complex -> Complex, static member witnesses.convert_witness : x:bigint * _output:bigint -> bigint, static member witnesses.convert_witness : x:bigint * _output:byte -> byte, static member witnesses.convert_witness : x:bigint * _output:decimal -> decimal, static member witnesses.convert_witness : x:bigint * _output:float -> float, static member witnesses.convert_witness : x:bigint * _output:float32 -> float32, static member witnesses.convert_witness : x:bigint * _output:int16 -> int16, static member witnesses.convert_witness : x:bigint * _output:int32 -> int, static member witnesses.convert_witness : x:bigint * _output:int64 -> int64, static member witnesses.convert_witness : x:bigint * _output:sbyte -> sbyte, static member witnesses.convert_witness : x:bigint * _output:uint16 -> uint16, static member witnesses.convert_witness : x:bigint * _output:uint32 -> uint32, static member witnesses.convert_witness : x:bigint * _output:uint64 -> uint64
|
|
@ -0,0 +1,67 @@
|
|||
module Neg129
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
//
|
||||
// This removes ^output as a type selector for the witness, but continues to pass a dummy ^output
|
||||
//
|
||||
// This is sufficient to make nearly all resolutions go through except when we instantiate by input type alone
|
||||
module Negative_SelectOverloadedWitnessBasedOnReturnTypeByPassingDummyArgumentNoOutputSelector =
|
||||
open System
|
||||
open System.Numerics
|
||||
let _uint8max = bigint (uint32 Byte.MaxValue)
|
||||
let _uint16max = bigint (uint32 UInt16.MaxValue)
|
||||
let _uint32max = bigint UInt32.MaxValue
|
||||
let _uint64max = bigint UInt64.MaxValue
|
||||
type witnesses =
|
||||
static member inline convert_witness (x : bigint, _output : int32) = int (uint32 (x &&& _uint32max))
|
||||
static member inline convert_witness (x : bigint, _output : int64) = int64 (uint64 (x &&& _uint64max))
|
||||
static member inline convert_witness (x : bigint, _output : bigint) = x
|
||||
static member inline convert_witness (x : bigint, _output : float) = float x
|
||||
static member inline convert_witness (x : bigint, _output : sbyte) = sbyte (byte (x &&& _uint8max))
|
||||
static member inline convert_witness (x : bigint, _output : int16) = int16 (uint16 (x &&& _uint16max))
|
||||
static member inline convert_witness (x : bigint, _output : byte) = byte (x &&& _uint8max)
|
||||
static member inline convert_witness (x : bigint, _output : uint16) = uint16 (x &&& _uint16max)
|
||||
static member inline convert_witness (x : bigint, _output : uint32) = uint32 (x &&& _uint32max)
|
||||
static member inline convert_witness (x : bigint, _output : uint64) = uint64 (x &&& _uint64max)
|
||||
static member inline convert_witness (x : bigint, _output : float32) = float32 x
|
||||
static member inline convert_witness (x : bigint, _output : decimal) = decimal x
|
||||
static member inline convert_witness (x : bigint, _output : Complex) = Complex(float x, 0.0)
|
||||
|
||||
let inline call_convert_witness< ^witnesses, ^input, ^output when (^witnesses or ^input) : (static member convert_witness : ^input * ^output -> ^output)> (b : ^input, c : ^output) =
|
||||
((^witnesses or ^input) : (static member convert_witness : ^input * ^output -> ^output) (b, c))
|
||||
|
||||
let inline convert num =
|
||||
call_convert_witness<witnesses, _, _> (num, Unchecked.defaultof<'b>)
|
||||
|
||||
// These are ok
|
||||
let v1 : int32 = convert 777I
|
||||
let v2 : int64 = convert 777I
|
||||
let v3 : bigint = convert 777I
|
||||
let v4 : float = convert 777I
|
||||
let v5 : sbyte = convert 777I
|
||||
let v6 : int16 = convert 777I
|
||||
let v7 : byte = convert 777I
|
||||
let v8 : uint16 = convert 777I
|
||||
let v9 : uint32 = convert 777I
|
||||
let v10 : uint64 = convert 777I
|
||||
let v11 : float32 = convert 777I
|
||||
let v12 : decimal = convert 777I
|
||||
let v13 : Complex = convert 777I
|
||||
|
||||
// These are ok
|
||||
let f1 : _ -> int32 = convert
|
||||
let f2 : _ -> int64 = convert
|
||||
let f3 : _ -> bigint = convert
|
||||
let f4 : _ -> float = convert
|
||||
let f5 : _ -> sbyte = convert
|
||||
let f6 : _ -> int16 = convert
|
||||
let f7 : _ -> byte = convert
|
||||
let f8 : _ -> uint16 = convert
|
||||
let f9 : _ -> uint32 = convert
|
||||
let f10 : _ -> uint64 = convert
|
||||
let f11 : _ -> float32 = convert
|
||||
let f12 : _ -> decimal = convert
|
||||
let f13 : _ -> Complex = convert
|
||||
|
||||
// This gives an error, because all selector types are known and overload resolution kicks in
|
||||
let inline inst (num: bigint) : ^output = convert num
|
|
@ -0,0 +1,315 @@
|
|||
module Pos35
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
//
|
||||
// We are selecting an overloaded witness based on input type
|
||||
module SelectOverloadedWitnessBasedOnInputType =
|
||||
type witnesses =
|
||||
static member inline unsigned_witness (x : sbyte) = uint8 x
|
||||
static member inline unsigned_witness (x : byte) = x
|
||||
static member inline unsigned_witness (x : int16) = uint16 x
|
||||
static member inline unsigned_witness (x : uint16) = x
|
||||
static member inline unsigned_witness (x : int32) = uint32 x
|
||||
static member inline unsigned_witness (x : uint32) = x
|
||||
static member inline unsigned_witness (x : int64) = uint64 x
|
||||
static member inline unsigned_witness (x : uint64) = x
|
||||
|
||||
// Note, this doesn't try to use the output to select
|
||||
let inline call_unsigned_witness< ^witnesses, ^input, ^output when (^witnesses or ^input) : (static member unsigned_witness : ^input -> ^output)> (x : ^input) =
|
||||
((^witnesses or ^input) : (static member unsigned_witness : ^input -> ^output) x)
|
||||
|
||||
// unsigned: ^a -> ^b
|
||||
let inline unsigned num = call_unsigned_witness<witnesses, _, _> num
|
||||
let v1 = unsigned 0y
|
||||
let v2 = unsigned 0s
|
||||
let v3 = unsigned 0
|
||||
let v4 = unsigned 0L
|
||||
|
||||
let f1 : int8 -> uint8 = unsigned
|
||||
let f2 : int16 -> uint16 = unsigned
|
||||
let f3 : int32 -> uint32 = unsigned
|
||||
let f4 : int64 -> uint64 = unsigned
|
||||
|
||||
let g1 : int8 -> _ = unsigned
|
||||
let g2 : int16 -> _ = unsigned
|
||||
let g3 : int32 -> _ = unsigned
|
||||
let g4 : int64 -> _ = unsigned
|
||||
|
||||
// Negative cases - not enough information here - see neg124.fs which checks these
|
||||
//let h1 : _ -> uint8 = unsigned
|
||||
//let h2 : _ -> uint16 = unsigned
|
||||
//let h3 : _ -> uint32 = unsigned
|
||||
//let h4 : _ -> uint64 = unsigned
|
||||
|
||||
|
||||
// Variation on the previous test case
|
||||
//
|
||||
// Note, this adds output as a selector though that shouldn't make any difference
|
||||
module SelectOverloadedWitnessBasedOnInputTypePlusNeedlessOutputTypeSelector =
|
||||
type witnesses =
|
||||
static member inline unsigned_witness (x : sbyte) = uint8 x
|
||||
static member inline unsigned_witness (x : byte) = x
|
||||
static member inline unsigned_witness (x : int16) = uint16 x
|
||||
static member inline unsigned_witness (x : uint16) = x
|
||||
static member inline unsigned_witness (x : int32) = uint32 x
|
||||
static member inline unsigned_witness (x : uint32) = x
|
||||
static member inline unsigned_witness (x : int64) = uint64 x
|
||||
static member inline unsigned_witness (x : uint64) = x
|
||||
|
||||
let inline call_unsigned_witness< ^witnesses, ^input, ^output when (^witnesses or ^input or ^output) : (static member unsigned_witness : ^input -> ^output)> (x : ^input) =
|
||||
((^witnesses or ^input or ^output) : (static member unsigned_witness : ^input -> ^output) x)
|
||||
|
||||
// unsigned: ^a -> ^b
|
||||
let inline unsigned num = call_unsigned_witness<witnesses, _, _> num
|
||||
let v1 = unsigned 0y
|
||||
let v2 = unsigned 0s
|
||||
let v3 = unsigned 0
|
||||
let v4 = unsigned 0L
|
||||
|
||||
let f1 : int8 -> uint8 = unsigned
|
||||
let f2 : int16 -> uint16 = unsigned
|
||||
let f3 : int32 -> uint32 = unsigned
|
||||
let f4 : int64 -> uint64 = unsigned
|
||||
|
||||
let g1 : int8 -> _ = unsigned
|
||||
let g2 : int16 -> _ = unsigned
|
||||
let g3 : int32 -> _ = unsigned
|
||||
let g4 : int64 -> _ = unsigned
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
module SelectOverloadedWitnessBasedOnReturnTypeByPassingDummyArgumentAndUsingOutputSelector =
|
||||
open System
|
||||
open System.Numerics
|
||||
let _uint8max = bigint (uint32 Byte.MaxValue)
|
||||
let _uint16max = bigint (uint32 UInt16.MaxValue)
|
||||
let _uint32max = bigint UInt32.MaxValue
|
||||
let _uint64max = bigint UInt64.MaxValue
|
||||
type witnesses =
|
||||
static member inline convert_witness (x : bigint, _output : int32) = int (uint32 (x &&& _uint32max))
|
||||
static member inline convert_witness (x : bigint, _output : int64) = int64 (uint64 (x &&& _uint64max))
|
||||
static member inline convert_witness (x : bigint, _output : bigint) = x
|
||||
static member inline convert_witness (x : bigint, _output : float) = float x
|
||||
static member inline convert_witness (x : bigint, _output : sbyte) = sbyte (byte (x &&& _uint8max))
|
||||
static member inline convert_witness (x : bigint, _output : int16) = int16 (uint16 (x &&& _uint16max))
|
||||
static member inline convert_witness (x : bigint, _output : byte) = byte (x &&& _uint8max)
|
||||
static member inline convert_witness (x : bigint, _output : uint16) = uint16 (x &&& _uint16max)
|
||||
static member inline convert_witness (x : bigint, _output : uint32) = uint32 (x &&& _uint32max)
|
||||
static member inline convert_witness (x : bigint, _output : uint64) = uint64 (x &&& _uint64max)
|
||||
static member inline convert_witness (x : bigint, _output : float32) = float32 x
|
||||
static member inline convert_witness (x : bigint, _output : decimal) = decimal x
|
||||
static member inline convert_witness (x : bigint, _output : Complex) = Complex(float x, 0.0)
|
||||
|
||||
let inline call_convert_witness< ^witnesses, ^input, ^output when (^witnesses or ^input or ^output) : (static member convert_witness : ^input * ^output -> ^output)> (b : ^input, c : ^output) =
|
||||
((^witnesses or ^input or ^output) : (static member convert_witness : ^input * ^output -> ^output) (b, c))
|
||||
|
||||
let inline convert num =
|
||||
call_convert_witness<witnesses, _, _> (num, Unchecked.defaultof<'b>)
|
||||
|
||||
let v1 : int32 = convert 777I
|
||||
let v2 : int64 = convert 777I
|
||||
let v3 : bigint = convert 777I
|
||||
let v4 : float = convert 777I
|
||||
let v5 : sbyte = convert 777I
|
||||
let v6 : int16 = convert 777I
|
||||
let v7 : byte = convert 777I
|
||||
let v8 : uint16 = convert 777I
|
||||
let v9 : uint32 = convert 777I
|
||||
let v10 : uint64 = convert 777I
|
||||
let v11 : float32 = convert 777I
|
||||
let v12 : decimal = convert 777I
|
||||
let v13 : Complex = convert 777I
|
||||
|
||||
// This is enough to determine the input as bigint because those are the only solutions available
|
||||
let f1 : _ -> int32 = convert
|
||||
let f2 : _ -> int64 = convert
|
||||
let f3 : _ -> bigint = convert
|
||||
let f4 : _ -> float = convert
|
||||
let f5 : _ -> sbyte = convert
|
||||
let f6 : _ -> int16 = convert
|
||||
let f7 : _ -> byte = convert
|
||||
let f8 : _ -> uint16 = convert
|
||||
let f9 : _ -> uint32 = convert
|
||||
let f10 : _ -> uint64 = convert
|
||||
let f11 : _ -> float32 = convert
|
||||
let f12 : _ -> decimal = convert
|
||||
let f13 : _ -> Complex = convert
|
||||
|
||||
// This is permitted because the ^output type is still a selector
|
||||
//
|
||||
// The resulting type is like this:
|
||||
//
|
||||
// val inline inst : num:bigint -> ^output when (witnesses or bigint or ^output) : (static member convert_witness : bigint * ^output -> ^output)
|
||||
let inline inst (num: bigint) : ^output = convert num
|
||||
let i1 : int32 = inst 777I
|
||||
let i2 : int64 = inst 777I
|
||||
let i3 : bigint = inst 777I
|
||||
let i4 : float = inst 777I
|
||||
let i5 : sbyte = inst 777I
|
||||
let i6 : int16 = inst 777I
|
||||
let i7 : byte = inst 777I
|
||||
let i8 : uint16 = inst 777I
|
||||
let i9 : uint32 = inst 777I
|
||||
let i10 : uint64 = inst 777I
|
||||
let i11 : float32 = inst 777I
|
||||
let i12 : decimal = inst 777I
|
||||
let i13 : Complex = inst 777I
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
// This removes ^output as a type selector for the witness, but continues to pass a dummy ^output
|
||||
//
|
||||
// This is sufficient to make the resolutions go through
|
||||
module SelectOverloadedWitnessBasedOnReturnTypeByPassingDummyArgumentNoOutputSelector =
|
||||
open System
|
||||
open System.Numerics
|
||||
let _uint8max = bigint (uint32 Byte.MaxValue)
|
||||
let _uint16max = bigint (uint32 UInt16.MaxValue)
|
||||
let _uint32max = bigint UInt32.MaxValue
|
||||
let _uint64max = bigint UInt64.MaxValue
|
||||
type witnesses =
|
||||
static member inline convert_witness (x : bigint, _output : int32) = int (uint32 (x &&& _uint32max))
|
||||
static member inline convert_witness (x : bigint, _output : int64) = int64 (uint64 (x &&& _uint64max))
|
||||
static member inline convert_witness (x : bigint, _output : bigint) = x
|
||||
static member inline convert_witness (x : bigint, _output : float) = float x
|
||||
static member inline convert_witness (x : bigint, _output : sbyte) = sbyte (byte (x &&& _uint8max))
|
||||
static member inline convert_witness (x : bigint, _output : int16) = int16 (uint16 (x &&& _uint16max))
|
||||
static member inline convert_witness (x : bigint, _output : byte) = byte (x &&& _uint8max)
|
||||
static member inline convert_witness (x : bigint, _output : uint16) = uint16 (x &&& _uint16max)
|
||||
static member inline convert_witness (x : bigint, _output : uint32) = uint32 (x &&& _uint32max)
|
||||
static member inline convert_witness (x : bigint, _output : uint64) = uint64 (x &&& _uint64max)
|
||||
static member inline convert_witness (x : bigint, _output : float32) = float32 x
|
||||
static member inline convert_witness (x : bigint, _output : decimal) = decimal x
|
||||
static member inline convert_witness (x : bigint, _output : Complex) = Complex(float x, 0.0)
|
||||
|
||||
let inline call_convert_witness< ^witnesses, ^input, ^output when (^witnesses or ^input) : (static member convert_witness : ^input * ^output -> ^output)> (b : ^input, c : ^output) =
|
||||
((^witnesses or ^input) : (static member convert_witness : ^input * ^output -> ^output) (b, c))
|
||||
|
||||
let inline convert num =
|
||||
call_convert_witness<witnesses, _, _> (num, Unchecked.defaultof<'b>)
|
||||
|
||||
let v1 : int32 = convert 777I
|
||||
let v2 : int64 = convert 777I
|
||||
let v3 : bigint = convert 777I
|
||||
let v4 : float = convert 777I
|
||||
let v5 : sbyte = convert 777I
|
||||
let v6 : int16 = convert 777I
|
||||
let v7 : byte = convert 777I
|
||||
let v8 : uint16 = convert 777I
|
||||
let v9 : uint32 = convert 777I
|
||||
let v10 : uint64 = convert 777I
|
||||
let v11 : float32 = convert 777I
|
||||
let v12 : decimal = convert 777I
|
||||
let v13 : Complex = convert 777I
|
||||
|
||||
// This is enough to determine the input as bigint because those are the only solutions available
|
||||
let f1 : _ -> int32 = convert
|
||||
let f2 : _ -> int64 = convert
|
||||
let f3 : _ -> bigint = convert
|
||||
let f4 : _ -> float = convert
|
||||
let f5 : _ -> sbyte = convert
|
||||
let f6 : _ -> int16 = convert
|
||||
let f7 : _ -> byte = convert
|
||||
let f8 : _ -> uint16 = convert
|
||||
let f9 : _ -> uint32 = convert
|
||||
let f10 : _ -> uint64 = convert
|
||||
let f11 : _ -> float32 = convert
|
||||
let f12 : _ -> decimal = convert
|
||||
let f13 : _ -> Complex = convert
|
||||
|
||||
// Adding this gives an error, see neg129.fs for the test for this
|
||||
// let inline inst (num: bigint) : ^output = convert num
|
||||
|
||||
// Variation on test case mentioned in https://github.com/dotnet/fsharp/pull/6805#issuecomment-580368303
|
||||
//
|
||||
// Same as SelectOverloadedWitnessBasedOnReturnTypeByPassingDummyArgumentNoOutputSelector but the output type
|
||||
// parameter is generic 'output rather than SRTP ^output
|
||||
//
|
||||
|
||||
module SelectOverloadedWitnessBasedOnReturnTypeByPassingDummyArgumentGenericOutputType =
|
||||
open System
|
||||
open System.Numerics
|
||||
let _uint8max = bigint (uint32 Byte.MaxValue)
|
||||
let _uint16max = bigint (uint32 UInt16.MaxValue)
|
||||
let _uint32max = bigint UInt32.MaxValue
|
||||
let _uint64max = bigint UInt64.MaxValue
|
||||
type witnesses =
|
||||
static member inline convert_witness (x : bigint, _output : int32) = int (uint32 (x &&& _uint32max))
|
||||
static member inline convert_witness (x : bigint, _output : int64) = int64 (uint64 (x &&& _uint64max))
|
||||
static member inline convert_witness (x : bigint, _output : bigint) = x
|
||||
static member inline convert_witness (x : bigint, _output : float) = float x
|
||||
static member inline convert_witness (x : bigint, _output : sbyte) = sbyte (byte (x &&& _uint8max))
|
||||
static member inline convert_witness (x : bigint, _output : int16) = int16 (uint16 (x &&& _uint16max))
|
||||
static member inline convert_witness (x : bigint, _output : byte) = byte (x &&& _uint8max)
|
||||
static member inline convert_witness (x : bigint, _output : uint16) = uint16 (x &&& _uint16max)
|
||||
static member inline convert_witness (x : bigint, _output : uint32) = uint32 (x &&& _uint32max)
|
||||
static member inline convert_witness (x : bigint, _output : uint64) = uint64 (x &&& _uint64max)
|
||||
static member inline convert_witness (x : bigint, _output : float32) = float32 x
|
||||
static member inline convert_witness (x : bigint, _output : decimal) = decimal x
|
||||
static member inline convert_witness (x : bigint, _output : Complex) = Complex(float x, 0.0)
|
||||
|
||||
let inline call_convert_witness< ^witnesses, ^input, 'output when (^witnesses or ^input) : (static member convert_witness : ^input * 'output -> 'output)> (b : ^input, c : 'output) =
|
||||
((^witnesses or ^input) : (static member convert_witness : ^input * 'output -> 'output) (b, c))
|
||||
|
||||
let inline convert num : 'output =
|
||||
call_convert_witness<witnesses, _, _> (num, Unchecked.defaultof<'output>)
|
||||
|
||||
let v1 : int32 = convert 777I
|
||||
let v2 : int64 = convert 777I
|
||||
let v3 : bigint = convert 777I
|
||||
let v4 : float = convert 777I
|
||||
let v5 : sbyte = convert 777I
|
||||
let v6 : int16 = convert 777I
|
||||
let v7 : byte = convert 777I
|
||||
let v8 : uint16 = convert 777I
|
||||
let v9 : uint32 = convert 777I
|
||||
let v10 : uint64 = convert 777I
|
||||
let v11 : float32 = convert 777I
|
||||
let v12 : decimal = convert 777I
|
||||
let v13 : Complex = convert 777I
|
||||
|
||||
// This is enough to determine the input as bigint because those are the only solutions available
|
||||
let f1 : _ -> int32 = convert
|
||||
let f2 : _ -> int64 = convert
|
||||
let f3 : _ -> bigint = convert
|
||||
let f4 : _ -> float = convert
|
||||
let f5 : _ -> sbyte = convert
|
||||
let f6 : _ -> int16 = convert
|
||||
let f7 : _ -> byte = convert
|
||||
let f8 : _ -> uint16 = convert
|
||||
let f9 : _ -> uint32 = convert
|
||||
let f10 : _ -> uint64 = convert
|
||||
let f11 : _ -> float32 = convert
|
||||
let f12 : _ -> decimal = convert
|
||||
let f13 : _ -> Complex = convert
|
||||
|
||||
// Adding this gives an error, see neg128.fs for the test for this
|
||||
// let inline inst (num: bigint) : 'output = convert num
|
||||
|
||||
|
||||
// Reduced FSharpPlus tests case from https://github.com/dotnet/fsharp/pull/6805#issuecomment-580365649
|
||||
module PositiveTestCase3 =
|
||||
[<AutoOpen>]
|
||||
module Extensions =
|
||||
|
||||
type Async<'T> with
|
||||
|
||||
static member Quack (x:seq<Async<'T>>) : Async<seq<'T>> = failwith ""
|
||||
|
||||
type Option<'T> with
|
||||
|
||||
static member Quack (x: seq<option<'T>>) : option<seq<'T>> = failwith ""
|
||||
|
||||
let inline CallQuack (x: ^a) : ^Output = (^a : (static member Quack : ^a -> ^Output) x)
|
||||
|
||||
type Witnesses =
|
||||
|
||||
static member inline QuackWitness (x: ^a, _output: ^Output, _impl: Witnesses) : ^Output = CallQuack x
|
||||
static member inline QuackWitness (x: ref<_>, _output: ^Output, _impl: Witnesses) : ^Output = Unchecked.defaultof<_>
|
||||
|
||||
let inline CallQuackWitness (x: ^a, output: ^Output, witnesses: ^Witnesses) =
|
||||
((^a or ^Output or ^Witnesses) : (static member QuackWitness : _*_*_ -> _) (x, output, witnesses))
|
||||
|
||||
let inline call (x: seq< ^b > ) : ^Output =
|
||||
CallQuackWitness (x, Unchecked.defaultof< ^Output >, Unchecked.defaultof<Witnesses>)
|
||||
|
||||
|
||||
|
|
@ -26,8 +26,6 @@ NOMONO,NoMT SOURCE=ConsumeOverloadGenericMethods.fs SCFLAGS="-r:lib.dll" PRECMD=
|
|||
|
||||
SOURCE=InferenceForLambdaArgs.fs # InferenceForLambdaArgs.fs
|
||||
|
||||
SOURCE=SlowOverloadResolution.fs # SlowOverloadResolution.fs
|
||||
|
||||
SOURCE=E_OverloadCurriedFunc.fs # E_OverloadCurriedFunc.fs
|
||||
SOURCE=E_OverloadMismatch.fs # E_OverloadMismatch.fs
|
||||
SOURCE=NoWarningWhenOverloadingInSubClass01.fs SCFLAGS="--warnaserror" # NoWarningWhenOverloadingInSubClass01.fs
|
||||
|
|
Загрузка…
Ссылка в новой задаче