[fpc-devel] Case of string
Bart
bartjunk64 at gmail.com
Thu Apr 26 19:29:26 CEST 2018
Hi,
Case of string evaluation seems to have changed from 3.0.4 to trunk.
program Project1;
{$mode objfpc}
{$h+}
var
s: string;
begin
repeat
readln(s);
case s of
'Hello', 'Hello2': writeln('In Hello');
'a'..'z': writeln('In ''a''..''z''');
else
writeln('In else');
end;
until (s = '');
end.
With 3.0.4 when the inout is 'qwerty' the output is 'In 'a'..'z'.
In trunk (r37889) the output will be:
'In Hello' for 'Hello' and 'Hello2'
'In 'a'..'z' only when the inout is 'a'
'In else' for every other input.
The 3.0.4 behaviour makes sense to me:( 'qwerty' > 'a') evaluates to
TRUE, as does ('qwerty' < 'z').
This might be unexpected to the programmer, but to me this indicates
using ranges with case of string is a bit dangerous.
The trunk behaviour makes no sense to me at all.
Is this a bug, or was it changed by design?
If the latter, why?
Bart
More information about the fpc-devel
mailing list