[fpc-pascal] modeswitch multihelpers precedence problem

Ryan Joseph genericptr at gmail.com
Wed Mar 11 02:48:39 CET 2020



> On Mar 10, 2020, at 8:09 PM, Anthony Walter <sysrpl at gmail.com> wrote:
> 
> An issue has been submitted here https://bugs.freepascal.org/view.php?id=36783 under the FPC compiler with tags "type helpers".


Can you make up an example that doesn't use SysUtils? Here's something I made up really quick but I don't see the bug.

All I did with multi helpers was continue the search which stopped at the first hit so all the normal overloading rules should apply as normal.

===================

{$mode objfpc}
{$modeswitch typehelpers}
{$modeswitch multihelpers}

program test;
uses
  umultihelpers_precedence0, 
  umultihelpers_precedence1;

begin
  'hello'.EndsWith('lo');
  IntToStr(12);
end.

===================

{$mode objfpc}
{$modeswitch typehelpers}
{$modeswitch mutlihelpers}

unit umultihelpers_precedence0;
interface

type
  TStringHelper = type helper for string
    function EndsWith(str: string): boolean;
  end;

function IntToStr(int: integer): string; 

implementation

function TStringHelper.EndsWith(str: string): boolean;
begin
  writeln('EndsWith - umultiplehelpers_precedence0');
end;

function IntToStr(int: integer): string; 
begin
  writeln('IntToStr - umultiplehelpers_precedence0');
end;

end.

===================

{$mode objfpc}
{$modeswitch typehelpers}
{$modeswitch mutlihelpers}

unit umultihelpers_precedence1;
interface

type
  TStringHelper = type helper for string
    function EndsWith(str: string): boolean;
  end;

function IntToStr(int: integer): string; 

implementation

function TStringHelper.EndsWith(str: string): boolean;
begin
  writeln('EndsWith - umultiplehelpers_precedence1');
end;

function IntToStr(int: integer): string; 
begin
  writeln('IntToStr - umultiplehelpers_precedence1');
end;

end.

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list