mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 13:59:28 +02:00
* allow char constant to be used for const string parameters in generic specializations, resolves #39030
git-svn-id: trunk@49569 -
This commit is contained in:
parent
ce1f9cce01
commit
51326e94f3
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -18880,6 +18880,7 @@ tests/webtbs/tw38940.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw3898.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3899.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3900.pp svneol=native#text/plain
|
||||
tests/webtbs/tw39030.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw3913.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3930.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3931a.pp svneol=native#text/plain
|
||||
|
@ -116,6 +116,9 @@ uses
|
||||
{ integer ords are compatible with float }
|
||||
else if (param1.typ=orddef) and is_integer(param1) and (param2.typ=floatdef) then
|
||||
result:=true
|
||||
{ chars are compatible with stringdef }
|
||||
else if (param1.typ=orddef) and is_char(param1) and (param2.typ=stringdef) then
|
||||
result:=true
|
||||
{ undefined def is compatible with all types }
|
||||
else if param2.typ=undefineddef then
|
||||
result:=true
|
||||
|
22
tests/webtbs/tw39030.pp
Normal file
22
tests/webtbs/tw39030.pp
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
{$mode objfpc}
|
||||
program gentest;
|
||||
|
||||
generic function ConstString<const P,Q,S: string>: PChar;
|
||||
var
|
||||
size: Integer;
|
||||
begin
|
||||
Size := SizeOf(P) + SizeOf(Q) + SizeOf(S);
|
||||
writeln(Size);
|
||||
|
||||
Result := P+Q+S;
|
||||
end;
|
||||
|
||||
var
|
||||
s: PChar;
|
||||
begin
|
||||
s := specialize ConstString<'Hello', ' world', '!'>; // error gentest.lpr(16,50) Error: Incompatible types: got "Char" expected "AnsiString"
|
||||
if s<>'Hello world!' then
|
||||
halt(1);
|
||||
writeln(s);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user