F# 6.0 -> 7.0: A unique overload for method could not be determined
See original GitHub issuePlease provide a succinct description of the issue.
I had the following TorchSharp code working fine in F# 6.0:
let xs = torch.zeros([|10L|], dtype=torch.float32)
After upgrading to F# 7.0 the compiler started complaining:
*A unique overload for method 'zeros' could not be determined based on type information prior to this program point. A type annotation may be needed.Known types of arguments: int64 array * dtype: torch.ScalarType * device: torch.Device * requiresGrad: bool
Candidates:
- torch.zeros(size: ReadOnlySpan<int64>, ?dtype: Nullable<torch.ScalarType>, ?device: torch.Device, ?requiresGrad: bool) : torch.Tensor
- torch.zeros(size: ReadOnlySpan<int64>, ?dtype: Nullable<torch.ScalarType>, ?device: torch.Device, ?requiresGrad: bool) : torch.Tensor
- torch.zeros(size: int64 array, ?dtype: Nullable<torch.ScalarType>, ?device: torch.Device, ?requiresGrad: bool) : torch.Tensor*
It does work in F# 7.0 if I change the code to:
let xs = torch.zeros([|10L|], ?dtype=Some torch.float32)
… but having to sprinkle this all over the code (in this way) is clumsy and hinders readability.
Yes, there’s a workaround,
but from a usability perspective, I’d call this a regression.
Issue Analytics
- State:
- Created 10 months ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
F# unique overload method
A unique overload for method 'Send' could not be determined based on type information prior to this program point. The available overloads ...
Read more >Apex Method Overloading is not working when called from ...
Each method you want to call must have a unique name. This is because of how the underlying API is designed. When calling...
Read more >Implementing a CE: Overloading
The error is: error FS0041: A unique overload for method 'Combine' could not be determined based on type information prior to this program...
Read more >Method overloading in the JVM
Because of the term overloading, developers tend to think this technique will overload the system, but that's not true.
Read more >Function overloading
In some programming languages, function overloading or method overloading is the ability to create multiple functions of the same name with different ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After discussing privately with @dsyme we concluded that for a fix here we should prefer nullable TDCs. I’ve implemented it in https://github.com/dotnet/fsharp/pull/14319. I have also opened https://github.com/dotnet/fsharp/issues/14318 to track the previously mentioned example which reproduces in F# 6 of an ambiguous set that clearly shouldn’t be.
Can I mark as closed by https://github.com/dotnet/fsharp/pull/14319 now ?