JetBrains/resharper-fsharp

False positive unused variables warning inside CEs

MangelMaxime opened this issue · 6 comments

I am using SqlHydra in one of my project. It uses CEs to build SQL queries and I found out that Rider report unused variables inside CEs even if they are used.

person and account are reported unused when they are actually used.

image

On simpler query without join the warning goes away:

image

I was able to reproduce the problem using Linq CE syntax:

image

Both place and place1 are reported unused.

let people = [
      ("Tomas", 1)
      ("Joe", 2)
      ("Don", 1)
  ]

  let places = [
      (1, "Cambridge")
      (2, "Wisconsin")
  ]

  let x = query {
      for person in people do
          join place in places on (snd person = fst place)
          join place1 in places on (snd person = fst place1) 
          select (fst person, snd place)
  }

Same happens when using SQLProvider

@MangelMaxime Thank you for reporting this. This warning is produced by FCS, and I've created an issue there: dotnet/fsharp#14566

@edgarfgp Could you share any example, please? Preferably, in the F# repo.

I'll close this issue, let's discuss it in the linked one instead.

I've pushed a temporary workaround on our side, until the issue is fixed in FCS.

Awesome thank you @auduchinok