Skip to content

ReadStr of enumerated type compiles only in {$mode objfpc}

  • Lazarus/FPC Version: Lazarus 2.2.2 (rev lazarus_2_2_2) FPC 3.2.2 x86_64-win64-win32/win64
  • Operating System: Windows 11
  • CPU / Bitness: 64 bit

What happens

Following codes do not compile in {mode delphi} while do compile in {mode objfpc}.

{$mode delphi}

type
   TInputTypes = (itText, itPassWord, itRadio, itCheckbox, itHidden, itTel,
                 itNumber, itUrl, itEmail, itRrange, itDate, itMonth, itWeek);
 
var
   ts: string;
   anIT: TInputTypes;
 
begin
   ts := 'itradio, tuesday, 3'; 
   ReadStr(ts, anIT); // <== this is not compiled ...  
end;

Error message : Typecast has different size (1 -> 4) in assignment

What did you expect

Hope that it compiles both in mode delphi and objfpc.

Steps to reproduce

Try to compile readstr procedure.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information