Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2021-12

Assigning class non-static methods, accessed via a helper type, to method pointers

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author
Subj silently produces invalid codegen:
-------8<-------
type C = class end;
type H = class helper for C
	class procedure Bar;
end;
class procedure H.Bar;
begin
	writeln('H.Bar(self=', ClassName, ')')
end;
var Z: procedure of object;
begin
	Z := H.Bar; // BadCG: GARBAGE
	// H.Bar; // REJECTED
end.
-------8<-------

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: -------8<-------
type H2 = class helper (H) for C

	class procedure Bar;

end;
-------8<-------

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 H.Bar
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.

βþ

Reply by email