Icon View Incident Report

Minor Minor
Reported By: Michael Dreher
Reported On: 9/25/2015
For: Version 2.01 Build 2
# 4255 Compiler Errors When Casting/Comparing Enumerated Types to Integers and Back

I've not fully understand the implicite enumeration to integer (and back) type conversion in the EWB Pascal. I get compiler errors.

type
 TTestInstructionDataType = ( 
   TIDT_INT,
   TIDT_FLOAT,
   TIDT_BOOL,
   TIDT_STRING
);

procedure TForm1.Button1Click(Sender: TObject);
var
 n : integer;
begin       
        
 // Comparing const int with enum member in a case statement, it compiles
 case 1  of
   TIDT_INT    : n:=1;
   TIDT_FLOAT  : n:=1;
   TIDT_BOOL   : n:=1;
   TIDT_STRING : n:=1;
 else
   n:=1;
 end;
        
 // Comparing const int with enum member in an IF statement.
 // Does not compile:
 // [Error] Unit1.wbs (45,10): Expected boolean, integer, or double but instead found TIDT_STRING
 {
 if 1 = TIDT_STRING then 
   n:=1;
 }

 // Make an explicite cast, this compiles
 // The case statement above does not need an explicite cast.
 if TTestInstructionDataType(1) = TTestInstructionDataType(TIDT_STRING) then
   n:=1;
     
 // Check some extension (using below), it compiles
 if (TTestInstructionDataType(1) = TTestInstructionDataType(TIDT_STRING)) then
   n:=1;   
    
 // Test AND operator in boolean expression (using below), it compiles
 if (1=1) AND (2=2) then 
   n := 1;       

 // Combine enumeration member (with explicite casting) and AND operator in IF statement:
 // Does not compile:
 // [Error] Unit1.wbs (66,7): Expected Boolean but instead found TTestInstructionDataType(1)  
 {
 if (TTestInstructionDataType(1) = TTestInstructionDataType(TIDT_STRING)) 
   AND (2=2) then
   n:=1;   
 }
end;



Resolution Resolution
Fixed Problem on 10/1/2015 in version 2.02 build 1


Products Affected Products Affected
Elevate Web Builder
Elevate Web Builder Trial

Image