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.

Improve error message for: "The type 'int' does not support the operator 'DivideByInt'"

See original GitHub issue

This was originally opened on CodePlex by latkin

Today this happened to me:

Microsoft (R) F# Interactive version 12.0.20809.1
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> [|2;4;6;8|] |> Seq.average;; 

> [|2;4;6;8|] |> Seq.average;;
  ---------------^^^^^^^^^^^

stdin(1,16): error FS0001: The type 'int' does not support the operator 'DivideByInt'

I was surprised to discover that int does not support DivideByInt. Since many times I have successfully divided ints by other ints.

I think we should either:

  • Make all numeric types that are divisible by int support DivideByInt or
  • improve the error message so that it’s not quite so head scratching.

comments dsyme wrote Jun 3, 2014 at 6:02 AM +1 for a better error message

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
pbachmanncommented, Jul 17, 2021

Thankfully, .NET has been integrated nicely and can substitute here …

let average = [2;4;6;8] |> System.Linq.Enumerable.Average

2reactions
KevinRansomcommented, Aug 22, 2016

@zpbappi , I’m going to close this the current error message and behaviour is at least explainable. Even if averaging a collection of ints seems like something the average API should actually be able to accomplish.

Kevin

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve error message for: "The type 'int' does not support ...
I was surprised to discover that int does not support DivideByInt. Since many times I have successfully divided ints by other ints.
Read more >
The type 'int' does not support the operator '=='
F# uses single = for equality operator: let t = seq { 1..10 } |> Seq.takeWhile (fun e -> e % 2 =...
Read more >
Troubleshooting F# | F# for fun and profit
After that, I will describe each of the common error messages in detail, and give ... The type 'int' does not support any...
Read more >
Choosing between collection functions · F# for Fun and Profit
Many of these functions are not yet documented on MSDN so I'm going to link ... The type 'int' does not support the...
Read more >
F# Math (IV.) - Writing generic numeric code
As we can see, the type needs to provide DivideByInt method (which takes integer as the second parameter) and a multiplication operator. The ......
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