[fpc-pascal] modeswitch multihelpers precedence problem

Ryan Joseph genericptr at gmail.com
Tue Mar 10 08:24:34 CET 2020



> On Mar 10, 2020, at 11:57 AM, Anthony Walter via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> To demonstrate, if I have MyUnit.pas that defines a string type helper with EndsWith() and an IntToStr() function then consider the following code:
> 
> program Test;
> 
> uses
>   MyUnit, SysUtils;
> 
> begin
>   'hello'.EndsWith('lo'); // invokes MyUnit.TStringHelper.EndsWith()
>   IntToStr(12); // invokes SysUtils.IntToStr()
> end.
> 

I think the problem here may be because SysUtils doesn't enable the mode switch. In that example above I would expect EndsWith to be used from the last unit, that is SysUtils. If you remake the example without SysUtils and define the type helpers in 2 units that both enable multihelpers  does it work correctly?

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list