question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

F# 6.0 -> 7.0: A unique overload for method could not be determined

See original GitHub issue

Please 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:closed
  • Created 10 months ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
NinoFloriscommented, Nov 14, 2022

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.

0reactions
T-Grocommented, Nov 16, 2022

Can I mark as closed by https://github.com/dotnet/fsharp/pull/14319 now ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found