I didn't mean it as a type check, I meant it more as a linter warning if == is statically impossible. A few languages and linters have some sort of Condition is always false warning.
In Crystal's case it would be based on type overlap. So the idea is that ARGV[0] == nil would trigger this linter rule (String and Nil don't overlap, so it's always false), but ARGV[0]? == nil wouldn't (String|Nil and Nil overlap).
I'm almost sure that there will be a lot of false positives, based on how the compiler and language works (or put another way: the type system.) Maybe there's a rule for this already in Ameba (a popular Crystal linter)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I didn't mean it as a type check, I meant it more as a linter warning if
==
is statically impossible. A few languages and linters have some sort ofCondition is always false
warning.In Crystal's case it would be based on type overlap. So the idea is that
ARGV[0] == nil
would trigger this linter rule (String
andNil
don't overlap, so it's alwaysfalse
), butARGV[0]? == nil
wouldn't (String|Nil
andNil
overlap).I'm not sure how practical that would be.
I'm almost sure that there will be a lot of false positives, based on how the compiler and language works (or put another way: the type system.) Maybe there's a rule for this already in Ameba (a popular Crystal linter)