This commit is contained in:
parent
f04a1c2161
commit
fe9d908f74
17
TestSuite/short_fun2.pas
Normal file
17
TestSuite/short_fun2.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
var i: integer;
|
||||||
|
type
|
||||||
|
t1 = class
|
||||||
|
procedure p1(x: integer);
|
||||||
|
begin
|
||||||
|
i := x
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
//Ошибка: Операция ':=' не применима к типу procedure(x: byte)
|
||||||
|
function f1(a: t1) := a.p1;
|
||||||
|
|
||||||
|
begin
|
||||||
|
var a: t1 := new t1;
|
||||||
|
f1(a)(2);
|
||||||
|
assert(i = 2);
|
||||||
|
end.
|
||||||
|
|
@ -1249,10 +1249,20 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
{
|
{
|
||||||
List<SymbolInfo> saved_sil = sil;
|
List<SymbolInfo> saved_sil = sil;
|
||||||
List<SymbolInfo> saved_sil2 = sil2;
|
List<SymbolInfo> saved_sil2 = sil2;
|
||||||
if (!(left is typed_expression))
|
base_function_call bfc = null;
|
||||||
AddError(new OperatorCanNotBeAppliedToThisTypes(name, left, right, loc));
|
if (!(left is typed_expression) && left.type is delegated_methods && name == ":=" && left is local_variable_reference && (left as local_variable_reference).var.type is undefined_type)
|
||||||
base_function_call bfc = ((left as typed_expression).type as delegated_methods).proper_methods[0];
|
{
|
||||||
left = convertion_data_and_alghoritms.explicit_convert_type(left, CreateDelegate(bfc.simple_function_node));
|
//left = convertion_data_and_alghoritms.explicit_convert_type(left, CreateDelegate((left.type as delegated_methods).proper_methods[0].simple_function_node));
|
||||||
|
left.type = CreateDelegate((left.type as delegated_methods).proper_methods[0].simple_function_node);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(left is typed_expression))
|
||||||
|
AddError(new OperatorCanNotBeAppliedToThisTypes(name, left, right, loc));
|
||||||
|
bfc = ((left as typed_expression).type as delegated_methods).proper_methods[0];
|
||||||
|
left = convertion_data_and_alghoritms.explicit_convert_type(left, CreateDelegate(bfc.simple_function_node));
|
||||||
|
}
|
||||||
|
|
||||||
sil = left.type.find_in_type(name);
|
sil = left.type.find_in_type(name);
|
||||||
if (!(right is typed_expression) && right.type is delegated_methods)
|
if (!(right is typed_expression) && right.type is delegated_methods)
|
||||||
bfc = (right.type as delegated_methods).proper_methods[0];
|
bfc = (right.type as delegated_methods).proper_methods[0];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue