Consider the following test program.
program test;
type Str255 = record sLength: Byte; sChars: packed array[1..255] of Char end;
operator + ( protected var s1, s2: Str255 ) = theResult : Str255; var len1, len2: Integer; begin len1 := s1.sLength; len2 := Min( 255 - len1, s2.sLength); theResult.sLength := len1 + len2; if len1 > 0 then theResult.sChars[1..len1] := s1.sChars[1..len1]; if len2 > 0 then theResult.sChars[len1+1..len1+len2] := s2.sChars[1..len2]; end;
var s1: Str255 value ( sLength: 1, sChars: 'A'); s2: Str255 value ( sLength: 1, sChars: 'B'); s3: Str255 value ( sLength: 1, sChars: 'C'); s4: Str255;
begin s4:=s1+s2+s3 { Error: reference expected, value given }; writeln( s4.sChars[ 1..s4.sLength]) end.
The program triggers an error for s1+s2+s3. The error doesn't occur when the expression has only one + operator (e.g. s1+s2). The problem disappears when using const parameters. It looks like the internal representation of an intermediate result is triggering the compiler error !
Regards,
Adriaan van Os