FsAutoComplete icon indicating copy to clipboard operation
FsAutoComplete copied to clipboard

FSAC0002 incorrectly tagged on nullable join clause in query expression

Open bisen2 opened this issue 4 years ago • 5 comments

In Ionide, the redundant qualifier tip (FSAC0002) is tagged on the first identifier when joining on a nullable property in a query expression. For example, if table1.column1 is of type int and table2.column2 is of type Nullable<int>, the following code snipped gets the FSAC0002 tip on row1 in row1.column1 =? row2.column2.

query {
    for row1 in table1 do
    join row2 in table2 on (row1.column1 =? row2.column2)
    select (row1, row2)
}

Here, the row1 identifier is actually not redundant and will break the code if removed. Interestingly, this only seems to happen when using the =? operator. If you write the same line with the condition as row1.column1 = row2.column2.value, no tool tip is shown.

bisen2 avatar Aug 10 '21 19:08 bisen2

thanks for the detailed report! Do you by any chance have some kind of self-contained sample that we could use to test/investigate with?

baronfel avatar Aug 10 '21 20:08 baronfel

Sure. Below is a code snippet that I can reproduce it with in an fsx file:

open System
open Microsoft.FSharp.Linq.NullableOperators

let table1 = [ for i in 0 .. 10 -> {| Column1 = i |} ]
let table2 = [ for i in 0 .. 10 -> {| Column2 = Nullable<int> i |} ]

query {
  for row1 in table1 do
  join row2 in table2 on (row1.Column1 =? row2.Column2)
  select (row1, row2)
}

And a screenshot of the tool tip generated: image

bisen2 avatar Aug 10 '21 20:08 bisen2

This is coming from FCS, we'd need this to be investigated and fixed upstream before it can work here. FSharp.Compiler.EditorServices.SimplifyNames.getSimplifiableNames says that row1.Column1 can be simplified, and we just report that.

baronfel avatar Apr 12 '22 03:04 baronfel