Var Formal Parameters Ignore String Lengths

Product Version(s): 3.20 3.3x
Operating System:   MS-DOS
Flags: ENDUSER | TAR15372
Last Modified:  3-OCT-1988    ArticleIdent: Q10382

Question:

Why does PAS1 fail to detect the type mismatch between
formal and actual lstring parameters of different lengths
in the following code?

   PROGRAM TEST_LSTRINGS(INPUT,OUTPUT);
   TYPE
   LONGTYPE=LSTRING(200);
   SHORTTYPE=LSTRING(10);
   VAR
   SHORTSTR:SHORTTYPE;

   PROCEDURE DUMMY(VAR LONG:LONGTYPE);
   VAR LOCLONG:LONGTYPE;
   BEGIN
   LOCLONG:='1234';
   LONG:=LOCLONG;
   END;

   BEGIN {MAIN}
   DUMMY(SHORTSTR);
   END.

Response:

Because the formal parameter of procedure dummy is declared to be of
type lstring (200), a type-mismatch error might be expected when dummy
is called with the actual parameter shortstr, which is a lstring of
length 10.

However, type checking in this case is explicitly disabled (and has
been for a long time, through many releases). Passing strings and
lstrings by reference using var or vars ignores the string lengths. As
a result, you are given the flexibility of using the same function or
procedure to process strings of different lengths.
