[DGD] Bad argument 2 - should be 1?
Felix A. Croes
felix at dworkin.nl
Mon Jul 18 18:48:02 CEST 2005
=?ISO-8859-1?Q?Petter_Nystr=F6m?= <md1pette at mdstud.chalmers.se> wrote:
> Running this code:
>
> string *a;
> a = nil; /* For emphasis. */
> a = a + ({"b"});
>
> Results in an error "Bad argument 2 for kfun +", shouldn't this be "Bad
> argument 1 for kfun +"? Not so big a thing, but it had me confused for a
> while as I searched for a bug in the wrong place.
This is a side effect of using a typechecking mode below 2, where nil is
equal to the integer value 0. Obviously, 0 is a proper first argument
for addition.
Provided that there is still some degree of typechecking enabled, you
could make the case that the interpreter knows at this point that the
first argument should be of type string*, and that a 0/nil value is
invalid. But accepting this has historically been the case for LPC,
and I consider any global typechecking mode below 2 as backward
compatible.
Regards,
Dworkin
More information about the DGD
mailing list