vishapoberon / compiler

vishap oberon compiler
http://oberon.vishap.am
GNU General Public License v3.0
186 stars 25 forks source link

comparing an open array with 0X character #16

Open norayr opened 8 years ago

norayr commented 8 years ago

imagine a procedure

PROCEDURE a(VAR s : ARRAY OF CHAR);

now let's say we want to test s[i] for something, but mistakenly write

IF s = 0X THEN

should there be warning or error about that?

dcwbrown commented 8 years ago

This is probably OK and equivalent to

IF s = "" THEN

The spec says in 3.4 that

A string of length 1 can be used wherever a character constant is allowed and vice versa.

So 0X is allowed wherever a string of length one is allowed, as I believe it is in this case.