On Sun, 6 Oct 2019 12:23:57 -0400 Ryan Joseph <generic...@gmail.com> wrote:
> > On Oct 6, 2019, at 12:18 PM, Mattias Gaertner via fpc-pascal > > <fpc-pascal@lists.freepascal.org> wrote: > > > > Ryan, is patch_3_25.diff the latest patch? > > > > I get a lot of merge conflicts. > > What fpc revision is needed for this? > > > > And what is the git repo > > https://github.com/genericptr/freepascal/tree/generic_implicit > > ? > > It does not contain the modeswitch. > > > > Mattias > > It’s the latest patch but that’s many months old already so nothing > is up to date. I failed multiple times to update my branch from the > “upstream" so I can't fix errors easily (there was a long thread some > months ago but I gave up). > > Look at the changes page on Github and search for > m_implicit_function_specialization. > > https://github.com/graemeg/freepascal/compare/master...genericptr:generic_implicit My mistake was to use git clone https://github.com/genericptr/freepascal.git. The zip contains a valid version. You implemented it pretty Delphi compatible. As you know, the Delphi help states wrongly, that type inference uses 32bit "integer" when possible, which would mean that often only one specialization is created. In reality it uses the smallest integer type, creating easily many different specializations, bloating up the exe. The Delphi compiler is really picky (dumb?) on type inference. That being said, I noticed several differences to Delphi (10.3): 1. FPC allows default params, Delphi does not. Nice. I see no tests for this though, so maybe this was not on purpose? 2. DoThis(1,200) gives range check warning instead of error. A warning means there are some rare cases, where this code is correct. Is this a todo or do you see a useful case? 3. timpfuncspez2.pp DoThis<T> DoThis<T,U> Delphi gives an error "Ambiguous call to DoThis". FPC silently selects the one with only one param. IMO this is dangerous, it should give an error. 4. Why does timpfuncspez6 fail? It works in Delphi. The comment has an explanation, which looks wrong to me: generic procedure DoThis<T,U>(msg: T; param1: U; param2: TObject); begin end; begin DoThis('aa', 'aa', TObject.Create); // wil be specialized as DoThis(msg: integer; param1: TObject; param2: TObject) // so we expect an incompatible type error DoThis(1, 1, TObject.Create); end. Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal