[fpc-pascal] generic proc inference
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Oct 7 11:08:46 CEST 2019
On Sun, 6 Oct 2019 18:16:16 -0400
Ryan Joseph <genericptr at gmail.com> wrote:
> > On Oct 6, 2019, at 5:40 PM, Mattias Gaertner via fpc-pascal
> > <fpc-pascal at lists.freepascal.org> wrote:
> >> Which test? Please post a sample.
> >
> > generic procedure DoThis<T>(a:T; b:T);
> > begin end;
> >
> > begin
> > DoThis(1,200); // 1 sets T to shortint, so the 200 gives a warning
> > end;
> >
>
> What is the preferred behavior? I’m getting an error in ObjFPC mode.
>
> {$mode objfpc}
> {$modeswitch implicitfunctionspecialization}
>
> program timpfuncspez16;
>
> generic procedure DoThis<T>(param1: T; param2: T);
> begin
> end;
>
> begin
> DoThis(1, 200);
> end.
I get only a Warning:
Warning: (4110) range check error while evaluating constants (200 must
be between -128 and 127)
Mattias
More information about the fpc-pascal
mailing list