Better diagnostic for calling Method(x = 0.5) when takes bool
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
I hope this is just one of those gotcha's that I sometimes have when I stare too long at the screen. With NUnit, this doesn't compile:
```f#
let x = 0.5
Asssert.IsTrue(x = 0.5) // FS0505
Asssert.IsFalse(x = 0.5) // FS0505
```
The error:
> FS0505: The member or object constructor 'IsTrue' does not take 0 argument(s). An overload was found taking 1 arguments.
However, these compile fine:
```f#
let x = 0.5
not(x = 0.5)
Assert.IsTrue(0.5 = 0.5)
Assert.IsFalse(0.4 = 0.5)
Assert.IsTrue(x <> 0.4)
Assert.IsFalse(x <> 0.5)
Assert.IsFalse((3.0 + 4.0) = result)
```
**Expected behavior**
I figured the above should not give a compile error.
**Actual behavior**
They raise FS0505. And it says "does not take 0 arguments", that doesn't seem right.
**Known workarounds**
Add an extra pair of parens.
**Related information**
As far as I can remember, any place that takes boolean can take a compare-operator, but apparently that isn't true for `=`, but only if the expression involves a variable identifier.
I have not checked other cases than the ones mentioned above, though I suspect it has something to do with the overload resolution, but that doesn't explain why it works with one operator, but not the other.
Or I'm totally missing the obvious :laughing:
Contributor guide
Assessment
This issue has not been assessed yet.