fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Some warnings are missing

Open matthid opened this issue 9 years ago • 7 comments

It seems like some warnings are missing from all recent IDEs (Rider, Visual Studio 2017, Ionide and FSI)

Repro steps

The following code contains a warning, as the generic parameter 'a is constrained to string because of the parameter f in cache.GetOrAdd(_, f):

let internal memoizeBy (getKey : 'a -> string) (f: 'a -> 'b) : 'a -> 'b =
   let cache = System.Collections.Concurrent.ConcurrentDictionary<string, 'b>()
   fun (x: 'a) ->
       cache.GetOrAdd(getKey x, f)

Use this code snippet in recent Visual Studio, Ionide or Rider.

Expected behavior

image

Actual behavior

No Warning at all.

Known workarounds

Use older versions

Related information

There have been reports on Slack that other warnings seem to be no longer shown (like "use new on IDisposable), but I haven't actually verified anything. ~~If the impact of this are indeed ALL warnings, the severity should be considered very high.~~ ~~Even if the impact is only for a particular subset of warnings I think the severity should still be considered high as missing this warning along can (an has already) cost a lot of hours and frustration.~~ While the above (striked through) is true, we have lived with this a long time. So I think it is serious but nobody noticed this for a long time (it is indeed hard to spot) ...

Also this seems to be a regression as it worked previously.

@Lleutch Did some testing and says this has been introduced "between FCS 9.0.1 and FCS 10.0.3"

/cc @Krzysztof-Cieslak @vasily-kirichenko @Lleutch

matthid avatar Oct 14 '17 11:10 matthid

I can reproduce it: no warnings for this specific function in latest VS 2017 and Rider: neither in the compiler output nor in the IDE. However, there is a warning for this simpler function:

default

vasily-kirichenko avatar Oct 14 '17 11:10 vasily-kirichenko

I can reproduce it on a ~10 months old revision (a7245c3c8645c24cde75d515f899d85481374a10), so it's not a very recent regression.

vasily-kirichenko avatar Oct 14 '17 12:10 vasily-kirichenko

I am adding that repo here : https://github.com/Lleutch/VFT-3752

It is regarding the different versions of FCS returning or not the expected warnings.

Lleutch avatar Oct 14 '17 12:10 Lleutch

@dsyme is it not considered a regression anymore?

matthid avatar Mar 09 '18 17:03 matthid

Yes, this is a regression - or at least the warning should be shown. I don't know why I changed the label

dsyme avatar Mar 10 '18 00:03 dsyme

So after fixing this it seems like the compiler has thrown all warnings away while doing overload resolution. This would explain @vasily-kirichenko's finding, and that other warnings might be missing as well.

matthid avatar Mar 10 '18 15:03 matthid

@matthid Super, thanks for looking into this

dsyme avatar Mar 12 '18 14:03 dsyme