Discussion:
FPC fails on overload
(too old to reply)
David Jenkins
2018-06-18 18:04:32 UTC
Permalink
The following code:


{$MODE DELPHI}

program CharOverload;

uses
  SysUtils;

procedure Foo(const aArg: UnicodeString); overload;
begin
  WriteLn('WideString: ', aArg);
end;

procedure Foo(c: WideChar); overload;
begin
  WriteLn('Char: ', c);
end;

begin
  Foo('abc');
end.


Fails with current trunk fpc with the following messages


[odysseus:fpc-trunk$] compiler/ppc386 ~/Desktop/test/CharOverload.pp
Free Pascal Compiler version 3.1.1 [2018/06/18] for i386
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Darwin for i386
Compiling /Users/djenkins/Desktop/test/CharOverload.pp
CharOverload.pp(19,3) Error: Can't determine which overloaded function
to call
CharOverload.pp(19,12) Error: Illegal type conversion: "Constant String"
to "WideChar"
CharOverload.pp(20,4) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted


It fails with same messages with {$MODE OBJFPC}.  Is this known. I can
enter a Mantis if desired.


Thanks

David Jenkins



_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi
Marcos Douglas B. Santos
2018-06-18 18:11:53 UTC
Permalink
On Mon, Jun 18, 2018 at 3:04 PM, David Jenkins
Post by David Jenkins
{$MODE DELPHI}
program CharOverload;
uses
SysUtils;
procedure Foo(const aArg: UnicodeString); overload;
begin
WriteLn('WideString: ', aArg);
end;
procedure Foo(c: WideChar); overload;
begin
WriteLn('Char: ', c);
end;
begin
Foo('abc');
end.
Fails with current trunk fpc with the following messages
[odysseus:fpc-trunk$] compiler/ppc386 ~/Desktop/test/CharOverload.pp
Free Pascal Compiler version 3.1.1 [2018/06/18] for i386
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Darwin for i386
Compiling /Users/djenkins/Desktop/test/CharOverload.pp
CharOverload.pp(19,3) Error: Can't determine which overloaded function to
call
CharOverload.pp(19,12) Error: Illegal type conversion: "Constant String" to
"WideChar"
CharOverload.pp(20,4) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
It fails with same messages with {$MODE OBJFPC}. Is this known. I can enter
a Mantis if desired.
Hey David,
The compiler says "Can't determine which overloaded function to call"
because both are strings.

Marcos Douglas
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepa
David Jenkins
2018-06-18 20:00:02 UTC
Permalink
This is something that has just recently stopped working for us(with update
to current trunk). We previously were using trunk rev 36812 with no
problems.


Placing a second call

foo('a')

calls the expected WideChar version.

David
Post by Marcos Douglas B. Santos
On Mon, Jun 18, 2018 at 3:04 PM, David Jenkins
Post by David Jenkins
{$MODE DELPHI}
program CharOverload;
uses
SysUtils;
procedure Foo(const aArg: UnicodeString); overload;
begin
WriteLn('WideString: ', aArg);
end;
procedure Foo(c: WideChar); overload;
begin
WriteLn('Char: ', c);
end;
begin
Foo('abc');
end.
Fails with current trunk fpc with the following messages
[odysseus:fpc-trunk$] compiler/ppc386 ~/Desktop/test/CharOverload.pp
Free Pascal Compiler version 3.1.1 [2018/06/18] for i386
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Darwin for i386
Compiling /Users/djenkins/Desktop/test/CharOverload.pp
CharOverload.pp(19,3) Error: Can't determine which overloaded function to
call
CharOverload.pp(19,12) Error: Illegal type conversion: "Constant String" to
"WideChar"
CharOverload.pp(20,4) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
It fails with same messages with {$MODE OBJFPC}. Is this known. I can enter
a Mantis if desired.
Hey David,
The compiler says "Can't determine which overloaded function to call"
because both are strings.
Marcos Douglas
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists
Florian Klämpfl
2018-06-18 20:01:29 UTC
Permalink
Post by David Jenkins
This is something that has just recently stopped working for us(with update
to current trunk).  We previously were using trunk rev 36812 with no
problems.
Please submit a bug report to mantis.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listin
David Jenkins
2018-06-18 21:56:45 UTC
Permalink
Done.  Mantis 33875.
Post by Florian Klämpfl
Post by David Jenkins
This is something that has just recently stopped working for us(with update
to current trunk).  We previously were using trunk rev 36812 with no
problems.
Please submit a bug report to mantis.
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal
Marcos Douglas B. Santos
2018-06-18 23:38:07 UTC
Permalink
Post by Florian Klämpfl
Post by David Jenkins
This is something that has just recently stopped working for us(with update
to current trunk). We previously were using trunk rev 36812 with no
problems.
Please submit a bug report to mantis.
Sorry, but how the compiler will know the correct string type of 'a'?
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/
J. Gareth Moreton
2018-06-19 00:47:04 UTC
Permalink
Technically it's a regression because it worked fine before and it breaks
now.  However, I do agree... how should a string literal be interpreted?
Technically either a WideString or UnicodeString is correct, so the
compiler cannot decide between them or even know what the best fit is.

Gareth
Post by Florian Klämpfl
Post by David Jenkins
This is something that has just recently stopped working for us(with
update
to current trunk). We previously were using trunk rev 36812 with no
problems.
Please submit a bug report to mantis.
Sorry, but how the compiler will know the correct string type of 'a'?
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org [2]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[3]">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel



Links:
Sven Barth via fpc-devel
2018-06-19 05:18:25 UTC
Permalink
Post by J. Gareth Moreton
Technically it's a regression because it worked fine before and it
breaks now.  However, I do agree... how should a string literal be
interpreted? Technically either a WideString or UnicodeString is
correct, so the compiler cannot decide between them or even know what
the best fit is.
It's an overload between UnicodeString and WideCHAR, not WideString, so
there is a definitive difference.

Regards,
Sven
J. Gareth Moreton
2018-06-19 11:42:53 UTC
Permalink
Oh whoops. My mistake.

On Tue 19/06/18 06:18 , Sven Barth via
Am 19.06.2018 um 02:47 schrieb J. Gareth
Technically it's a regression because it
worked fine before and it
breaks now.  However, I do agree... how
should a string literal be
interpreted? Technically either a
WideString or UnicodeString is correct,
so the compiler cannot decide between
them or even know what the best fit
is. It's an overload between
UnicodeString and WideCHAR, not
WideString, so
there is a definitive difference.
Regards,
Sven
__________________________________________
_____
fpc-devel maillist - fpc-
http://lists.freepascal.org/cgi-
bin/mailman/listinfo/fpc-devel [1]
------
[1]
http://secureweb.fast.net.uk/parse.php?
redirect=http://lists.freepascal.org
/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/

Loading...