This commit is contained in:
Ivan Bondarev 2022-01-09 12:27:02 +01:00
parent acff3ab3a3
commit 3666453683
3 changed files with 49 additions and 1 deletions

View file

@ -0,0 +1,19 @@
var i: integer;
type
t1 = class
static function operator implicit<T>(o: T): t1;
begin
i := 1;
Result := nil;
end;
end;
function f0: t1 := nil;
procedure p0(o: t1) := exit;
begin
var o: t1 := f0;
assert(i = 0);
end.

View file

@ -0,0 +1,22 @@
var i: integer;
type
t1 = class
// Обязательно шаблонный operator implicit
static function operator implicit<T>(o: T): t1;
begin
i := 1;
Result := nil;
end;
end;
function f0: t1 := nil;
procedure p0(o: t1) := exit;
begin
// Обязательно вызвать f0 без скобок
// Если поставить скобки - не воспроизводится
p0(f0);
assert(i = 0);
end.

View file

@ -658,6 +658,11 @@ namespace PascalABCCompiler.TreeConverter
if (pct.second!=null)
{
if (pct.second.to == null && en is typed_expression && !to.IsDelegate)
{
syntax_tree_visitor.try_convert_typed_expression_to_function_call(ref en);
return en;
}
AddError(new TwoTypeConversionsPossible(en,pct.first,pct.second));
}
@ -1831,7 +1836,7 @@ namespace PascalABCCompiler.TreeConverter
{
if (ptc.second!=null)
{
if (ptc.first.from is null_type_node || ptc.second.from is null_type_node || ptc.second.from.is_generic_parameter)
if (ptc.first.from is null_type_node || ptc.second.to == null || ptc.second.from is null_type_node || ptc.second.from.is_generic_parameter)
continue; // SSM 9/12/20 fix 2363
AddError(new PossibleTwoTypeConversionsInFunctionCall(loc,ptc.first,ptc.second));
}
@ -1888,6 +1893,8 @@ namespace PascalABCCompiler.TreeConverter
{
continue;
}
if (ptcal[i].second != null && ptcal[i].second.to == null)
continue;
expression_node[] temp_arr = new expression_node[1];
temp_arr[0] = exprs[i];
if (ptcal[i].first.convertion_method is compiled_constructor_node)