This commit is contained in:
Бондарев Иван 2016-08-03 21:24:30 +02:00
parent 1d6dfe245a
commit 132b1e2de2
2 changed files with 22 additions and 1 deletions

18
TestSuite/params10.pas Normal file
View file

@ -0,0 +1,18 @@
function f<T>(params a: array of T): array of T;
begin
Result := a;
end;
function f2<T>(b: T; params a: array of T): array of T;
begin
Result := a;
end;
begin
var a := new integer[3](1,2,3);
var b: array of integer;
b := f(a);
assert(b[0] = 1);
b := f2(2, a);
assert(b[1] = 2);
end.

View file

@ -809,7 +809,10 @@ namespace PascalABCCompiler.TreeRealization
for (int i = formal_count - 1; i < fact_count; ++i) for (int i = formal_count - 1; i < fact_count; ++i)
{ {
//Проверяем фактические, попадающие под params... //Проверяем фактические, попадающие под params...
if (!DeduceInstanceTypes(last_params_type, fact[i].type, deduced, nils)) type_node tn = fact[i].type;
if (tn.element_type != null && tn.type_special_kind != SemanticTree.type_special_kind.array_wrapper)
tn = tn.element_type;
if (!DeduceInstanceTypes(last_params_type, tn, deduced, nils))
{ {
if (alone) if (alone)
throw new SimpleSemanticError(loc, "GENERIC_FUNCTION_{0}_CAN_NOT_BE_CALLED_WITH_THESE_PARAMETERS", func.name); throw new SimpleSemanticError(loc, "GENERIC_FUNCTION_{0}_CAN_NOT_BE_CALLED_WITH_THESE_PARAMETERS", func.name);