DEV Community

Discussion on: Open Source Adventures: Episode 75: Issues with Crystal Char type

 
taw profile image
Tomasz Wegrzanowski

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 not sure how practical that would be.

Thread Thread
 
asterite profile image
Ary Borenszweig

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)