* create_for_in_loop: if there's a choice between iterating an array and a set then prefer the set for backwards compatibility

git-svn-id: trunk@36097 -
This commit is contained in:
svenbarth 2017-05-04 21:38:00 +00:00
parent a8b1d340c7
commit c6f19b9888

View File

@ -925,6 +925,15 @@ implementation
end
else
begin
{ prefer set if loop var could be a set var and the loop
expression can indeed be a set }
if (expr.nodetype=arrayconstructorn) and
(hloopvar.resultdef.typ in [enumdef,orddef]) and
arrayconstructor_can_be_set(expr) then
begin
expr:=arrayconstructor_to_set(expr,false);
typecheckpass(expr);
end;
case expr.resultdef.typ of
stringdef: result:=create_string_for_in_loop(hloopvar, hloopbody, expr);
arraydef: result:=create_array_for_in_loop(hloopvar, hloopbody, expr);