Lint suggests "not (isNull x)" over "x <> null"
See original GitHub issueDescription
The linter suggests replacing a null check (x <> null
) with the more complicated not (isNull x)
. I’m not coming up with any cases where I think a null check would be better as not (isNull x)
.
Repro steps
Please provide the steps required to reproduce the problem
-
Add a
<> null
check to your F# code -
View linter error
Expected behavior
The linter doesn’t warn on <> null
checks.
Actual behavior
The linter warns on <> null
checks.
Known workarounds
Disable the linter.
Related information
- Operating system
- Branch
- .NET Runtime, CoreCLR or Mono Version
- Performance information, links to performance testing scripts
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Open up isNotNull, adding it to the top-level functions for ...
Linter currently suggests use of isNull when it sees x == null or x <> null , which leads to debate in the...
Read more >Why does NULL = NULL evaluate to false in SQL server
The expression "NULL = NULL" evaluates to NULL, but is actually invalid in SQL; yet ORDER BY treats NULLs as equal (whatever they...
Read more >ISNULL vs IS NULL performance
Hello all,. I have a question on what the major differences for performance between using. WHERE field IS NULL. vs. WHERE ISNULL(field,0) =0....
Read more >Understanding null safety
Null safety eliminates that problem at the root by changing the type hierarchy. The Null type still exists, but it's no longer a...
Read more >IsNull function (Visual Basic for Applications) - VBA
Returns a Boolean value that indicates whether an expression contains no valid data (Null). Syntax. IsNull(expression). The required expression ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wonder if this is still true today. Lots of work went into optimization in both F# and the JIT since then.
I tried it quickly on SharpLab (link) and the generated code was properly inlined.Well, nevermind, it`s still bad.
@abelbraaksma Yes it is, but we changed from using attributes to using comments for that. But you cannot disable a specific hint, you can only disable all Hints. In this case you could add something like
// fsharplint:disable Hints
.I had suggested removing the hint from the config itself as then you can disable just that hint, and it sounded like that’s what was wanted. But I agree with you that this is useful hint and probably best to keep it on by default.