This commit is contained in:
Ivan Bondarev 2021-01-08 14:49:07 +01:00
parent a18fd381b7
commit af1b9b85f4
3 changed files with 35 additions and 2 deletions

View file

@ -0,0 +1,14 @@
type
t1 = class
static function operator implicit<T>(o: T): t1;
where T: record;
begin end;
end;
t2 = class end;
procedure p1(q: t1) := exit;
begin
p1(new t2);//Здесь теперь правильная ошибка: Нельзя преобразовать тип t2 к t1
end.

View file

@ -0,0 +1,19 @@
var i: integer;
type
t1 = class
static function operator implicit<T>(o: T): t1;
where T: record;
begin
i := 1;
end;
end;
t2 = class(t1) end;
procedure p1(q: t1) := exit;
begin
//Ошибка: Невозможно инстанцировать, так как тип t2 не является размерным
p1(new t2);
assert(i = 0);
end.

View file

@ -2331,7 +2331,7 @@ namespace PascalABCCompiler.TreeRealization
{
if (ctn.IsPointer)
continue;
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), true, null);
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), false, null);
}
}
return fn;
@ -2373,7 +2373,7 @@ namespace PascalABCCompiler.TreeRealization
ctn = (ctn as ref_type_node).pointed_type;
if (ctn.IsPointer)
continue;
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), true, null);
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), false, null);
}
}
return fn;