Wrong code generated for literal array of string in for-in loop
Original Reporter info from Mantis: leledumbo_cool@yahoo.co.id @leledumbo
-
Reporter name: Mario Ray Mahardhika
Original Reporter info from Mantis: leledumbo_cool@yahoo.co.id @leledumbo
- Reporter name: Mario Ray Mahardhika
Description:
Currently, the compiler only considers the first element to determine subsequent elements length, which is of course wrong. However, when the literal array is cast into dynamic array of string, the generated code is correct.
Steps to reproduce:
Compile the following program:
var
s: String;
begin
for s in (['1char','2chars']) do
WriteLn(s);
end.
it will output:
1char
2char
instead of the expected:
1char
2chars
Additional information:
Modify above program to:
uses
SysUtils;
type
TStringArray = specialize TArray<String>;
var
s: String;
begin
for s in TStringArray(['1char','2chars']) do
WriteLn(s);
end.
and the output will be as expected:
1char
2chars
Mantis conversion info:
- Mantis ID: 32034
- OS: linux
- OS Build: Rolling release
- Platform: x86_64
- Version: 3.1.1
- Monitored by: » tennis (Runar Tenfjord)