[fpc-devel] Assigning class non-static methods, accessed via a helper type, to method pointers

Blaise at blaise.ru Blaise at blaise.ru
Thu Dec 23 15:12:26 CET 2021

Subj silently produces invalid codegen:
type C = class end;
type H = class helper for C
	class procedure Bar;
class procedure H.Bar;
	writeln('H.Bar(self=', ClassName, ')')

var Z: procedure of object;
	Z := H.Bar; // BadCG: GARBAGE
	// H.Bar; // REJECTED

What is the consensus on:
A) fixing the codegen?
B) rejecting such access?

DCC does reject both statements, but it is not consistent with rejecting such qualifications everywhere.

Practically, allowing such qualifications could be useful for selecting a particular method. For example:
type H2 = class helper (H) for C
	class procedure Bar;

Also, despite the comment in tcallnode.pass_1 saying:
> 	CGMessage(parser_e_no_category_as_types);
> 	{ we get an internal error when trying to insert the hidden
> 	parameters in this case }
when I comment out the call to CGMessage, I get no ICE for
only EXTDEBUG warnings:
> Warning: Expectloc is not set in firstpass: calln
> Warning: ExpectLoc is not set before secondpass: calln
> Warning: Location (LOC_VOID) not equal to expectloc (LOC_INVALID): calln
and invalid codegen.


More information about the fpc-devel mailing list