Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Generics    [ Add a report in this area ]  
Report #:  118446   Status: Closed
[Regression in XE4] if-in statement for nested set type in parametrized class/record fails
Project:  Delphi Build #:  18.0.4905.60485
Version:    18.1 Submitted By:   Dmitriy Kaygorodtsev
Report Type:  Basic functionality failure Date Reported:  8/30/2013 12:30:10 AM
Severity:    Critical / Show Stopper Last Updated: 4/15/2014 6:41:37 PM
Platform:    All platforms Internal Tracking #:   42913
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE6
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 30
Description
[Regression in XE4] if-in statement for nested set type in parametrized class/record fails

This code works perfect in Delphi XE3, but it doesn't work in XE4 and XE4 Update1.
Steps to Reproduce:
------------
type
   NestedTest<T> = record
   strict private type
     TestSetType = set of 0..255;
   strict private
     FTestSet: TestSetType;
   public
     function TestSetTypeProc: Boolean; inline;
   end;

function NestedTest<T>.TestSetTypeProc: Boolean;
var
  I: UInt8;
begin
  for I := Low(I) to High(I) do
    if I in FTestSet then // <<<------ [dcc32 Error] E2015 Operator not applicable to this operand type
      ;
end;
------------
Workarounds
None
Attachment
None
Comments

Dmitry Burov at 8/30/2013 6:22:15 AM -
Minimized and reproducible example: http://pastebin.com/paaexX61

Program properly works in Xe2 but does not even compile in XE4u1

Dmitry Burov at 8/30/2013 6:22:43 AM -
program qc118446;
{$APPTYPE CONSOLE}

type
    NestedTest<T> = record
     type TestSetType = set of byte;
     var  FTestSet: TestSetType;
     function CalcRaisedBits1: integer;
     function CalcRaisedBits2: integer;
    end;
  
function NestedTest<T>.CalcRaisedBits1: integer;
var
    I: byte;
begin
    Result := 0;
    for I := Low(I) to High(I) do
      if I in FTestSet then // [dcc32 Error]  E2015 Operator not applicable to this operand type
        Inc(Result);
end;

function NestedTest<T>.CalcRaisedBits2: integer;
var
    I: byte;
begin
    Result := 0;
    for I in FTestSet do // [dcc32 Fatal Error]  F2084 Internal Error: E4260
        Inc(Result);
end;


var Rec: NestedTest<boolean>;

begin
   Rec.FTestSet := [10, 20, 30, 40];
   Writeln(4, ' == ', Rec.CalcRaisedBits1, ' == ', Rec.CalcRaisedBits2);
   ReadLn;
end.

Server Response from: ETNACODE01