Counter intuitive character comparison handling.
JettMonstersGoBoom opened this issue · 2 comments
JettMonstersGoBoom commented
example fail case.
line = readline() if (line[0]=="y") { // this comparison will ALWAYS fail. }
The output assembly looks like it's comparing against the address of the text literal "y" .
whereas
if (line[0]=="y"[0]) { // correctly detects y }
this is a cause for confusion, especially new users, ( one of whom I helped tracked down this issue )
KarolS commented
Thanks for the idea, I added a warning:
WARN: (:5:6) Comparison between a byte and a pointer is usually pointless.
if b == "h" { f() }
^
INFO: (:5:11) Did you mean to use a character literal here?
if b == "h" { f() }
^
WARN: (:6:6) Comparison between a byte and a pointer is usually pointless.
if b == b.pointer { f() }
^
WARN: (:7:6) Comparison between a byte and a pointer is usually pointless.
if b == b.addr { f() }
^
BTW, why did you use"y"[0]
instead of 'y'
?
JettMonstersGoBoom commented
for some reason I thought 'y' wasn't supported.