[fpc-pascal] generic proc inference

Ryan Joseph genericptr at gmail.com
Mon Mar 30 11:10:32 CEST 2020

I hope you're all having a lovely Coronavirus lockdown-vacation and keeping safe. :)

I finally got around to the overhaul of {$modeswitch implicitfunctionspecialization} as according to feedback in this thread. I attached a patch in the bug tracker which should apply without conflicts. In particular, Mattias, if you remember any of this please re-test and see if it works better now (I didn't include any tests yet). As for Sven I've left my design notes for you to review. I think I did what you wanted and the overloading works correctly now.

from the bug tracker:



I've done an overhaul on the previous design so I'm posting a patch which is a draft version (with debug writeln's as placeholders for proper error messages). If the design is sane I will clean everything up and probably inline some functions.

1) the entire inference process is redone according to feedback (see try_implicit_specialization).
   - array types and function pointers can be used for specialization.
   - templates can appear in any order now DoThis<T,U>(a: U; b: T);
2) as was requested by Sven the dummy syms are now valid procsyms and are passed along to tcallcandiates for overloading.
3) The inference is done at one location in do_proc_call but we could possibly move that inside tcallnode.pass_typecheck if it were better for some reason.
4) I added a tprocsym.add_generic_candiate to associate procsyms with dummy procsyms but I wasn't sure if this was good design so it's not cpu compliment and thus specialization from units will fail.
5) non-generic overloads are filtered in htypechk.is_better_candidate but I don't feel like I integrated my check in the right place due to me not really understanding that function.

	Ryan Joseph

More information about the fpc-pascal mailing list