Sign in Join

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

Mailing lists / fpc-devel / 2020-12

Method pointers to RECORD methods

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Unknown author

The patch http://hg.blaise.ru/public/fpc/rev/0a8aff8d8273 (attached) fixes the following: -------8<-------
{$Mode Delphi}

type R = record
	var X: Integer;
	function Foo: Integer;
end;
function R.Foo: Integer;
begin
	result := X
end;
var	F: function : Integer of object;
	Z: R = (X:42);
begin
	// EXPECTED: gets compiled
	// ACTUAL: 'Error: Incompatible types'
	F := Z.Foo;
	writeln( F() = 42 )
end.
-------8<-------

The patch does not check for m_delphi: I did not came up with a case where that would make a semantic difference.

βþ

Reply by email

Sven Barth
to Unknown author
Blaise--- wrote 27 lines
The patch http://hg.blaise.ru/public/fpc/rev/0a8aff8d8273 (attached) fixes the following: -------8<------- {$Mode Delphi} type R = record     var X: Integer;     function Foo: Integer; end; function R.Foo: Integer; begin     result := X end; var    F: function : Integer of object;     Z: R = (X:42); begin     // EXPECTED: gets compiled     // ACTUAL: 'Error: Incompatible types'     F := Z.Foo;     writeln( F() = 42 ) end. -------8<------- The patch does not check for m_delphi: I did not came up with a case where that would make a semantic difference.

Hadn't thought that Delphi allows this... anyway, applied in r47794.

Regards,
Sven

Reply by email