-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operators.( .. .. ) throws an ArgumentException when ^Step does not implement IComparable #6238
Comments
This seems odd at first glance. The implementation of fsharp/src/FSharp.Core/prim-types.fs Lines 5790 to 5796 in fc42ec9
fsharp/src/FSharp.Core/prim-types.fs Lines 5942 to 5944 in fc42ec9
fsharp/src/FSharp.Core/prim-types.fs Line 6032 in fc42ec9
fsharp/src/FSharp.Core/prim-types.fs Lines 6911 to 6912 in fc42ec9
The signature for fsharp/src/FSharp.Core/prim-types.fsi Lines 3756 to 3762 in fc42ec9
It would be a compile-time breaking change to update the signature for |
It seems like auto-inference doesn't add the
But also note that the |
@brianrourkeboll, I don't know if you tested the OP's example code, but I just tried it with the latest from
This member is clearly accessible... This, I think, is a regression. I cannot repro this with the latest RTM of F#. |
Hmm, I do not get that when using a VSIX built from |
Ok, this is weird. I pasted it under Once I put the code in a public module, it worked as expected. Note that, if I change the definition to be this (as you suggested): val inline (.. ..): start: ^T -> step: ^Step -> finish: ^T -> seq< ^T >
when (^T or ^Step): (static member (+): ^T * ^Step -> ^T)
and ^Step: (static member Zero: ^Step)
and ^T: equality
and ^T: comparison
and ^Step: equality
and ^Step: comparison
and default ^Step: ^T
and default ^T: int it will behave as the OP suggested (though the error is thrown 8 times???)
|
That seems to be #16762. |
Fixes dotnet#6238. Compiler does not infer this automatically through `and default`.
Fixes dotnet#6238. Compiler does not infer this automatically through `and default`.
Fixes dotnet#6238. Compiler does not infer this automatically through `and default`.
Operators.( .. .. )
throws anArgumentException
when^Step
does not implement non-genericSystem.IComparable
.Repro steps
Run the following code:
Expected behavior
I would expect a compiler error. Similar to
Step.Zero
not implementedValue.(+)
not implementedValue
not implementingSystem.IComparable
Actual behavior
The last line throws this exception:
Known workarounds
Run the code and realize you need to implement the interface
System.IComparable
onStep
:Or not using the
start .. step .. finish
operator, but generate the sequence somehow different (wherestep
is not required to be comparable toZero
at runtime).Related information
I had this issue when using 2 structs defined in C# and tried to iterate over them.
The text was updated successfully, but these errors were encountered: