KarolS/millfork

Counter intuitive character comparison handling.

JettMonstersGoBoom opened this issue · 2 comments

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 )

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'?

for some reason I thought 'y' wasn't supported.