Reviewing https://github.com/crystal-lang/crystal/issues/10277 again... I just had a case where I was comparing types that will never match (if x == y), taking me a while to find the bug. Given that 1.0 has been released, clearly changing the behavior of == won't happen. And although I'd very much prefer to do the investigation into in how many places exactly == is used to validly compare non-matching types, I don't see when at
all I could attempt this.
I don't particularly like the idea in the ticket to use #eql?, because my code would basically use #eql? in all places, #eql? would be used much more often than #==, but it's inconvenient to write (both itself being an abbreviation, plus requiring shift in english keyboards to type the '?')
I am probably going to do a quick code that can be hooked in via reopening classes, which modifies those default implementations of ==, to report the types being compared to STDERR. So I can run it a couple times to review the program, then disable it.
That's a method I used previously and it was effective... Most of the time I found invalid comparisons between Char and Strings
I suppose maybe a linter could do such type validations
arestifo has quit [Ping timeout: 245 seconds]
arestifo has joined #crystal-lang
That's a good idea... I think back then someone was saying on IRC that it had no place in linter, but I don't see why not... especially since it does the checks at final app level, so it can check user's own code, while not dealing with anything from built-in crystal
I might create an issue in ameba just to test the waters
rem has joined #crystal-lang
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Huh, we totally should allow comparing String and Char
`'a' == "a"` and `"a" == 'a'"` should be true IMO