Russian letters are not accepted in the case statement
Original Reporter info from Mantis: Kryvichh
-
Reporter name:
Original Reporter info from Mantis: Kryvichh
- Reporter name:
Description:
When I use a Russian letter as a constant expression in the case statement, Pas2js refuses to compile the code and gives errors: "Incompatible types: got "Char" expected "Char"", or "char expected, but string found".
No matter what encoding I use for the source file: ANSI CP1251 or UTF-8. In any other statements Pas2js accepts Russian letters without problems.
Steps to reproduce:
program TestRussianLetterInCase;
var
ch: Char;
begin
Writeln('Hello, world!');
ch := 'Я'; // No problem here
case ch of
'А': Writeln('This is Russian "A"'); // Error: Incompatible types: got "Char" expected "Char" (???)
'Б'..'Я': Writeln('This is other Russian letter'); // Error: char expected, but string found
end;
end.
Additional information:
Workaround: to declare constants and use these constants in the case statement:
program TestRussianLetterInCaseOK;
const
ckbA = #$410; // Russian letter A
ckbB = #$411; // Russian letter B
ckbYa = #$42F; // Russian letter Ya
var
ch: Char;
begin
Writeln('Hello, world!');
ch := 'Я';
case ch of
ckbA: Writeln('This is Russian "A"'); // OK
ckbB..ckbYa: Writeln('This is other Russian letter'); // OK
end;
end.
Test application is attached.
Mantis conversion info:
- Mantis ID: 34925
- OS: Windows
- OS Build: 7
- Fixed in revision: 41058.