fix #1512
This commit is contained in:
parent
46ce289724
commit
acaabbb319
13
TestSuite/delegates15.pas
Normal file
13
TestSuite/delegates15.pas
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
function f1(b: byte) := b;
|
||||||
|
function f2 := 2;
|
||||||
|
type fnc = function(b: byte): byte;
|
||||||
|
begin
|
||||||
|
var o1: object := f1;
|
||||||
|
var f: fnc := fnc(o1);
|
||||||
|
assert(f(2) = 2);
|
||||||
|
var o2: object := f2;
|
||||||
|
assert(integer(o2) = 2);
|
||||||
|
o1 := f1;
|
||||||
|
f := fnc(o1);
|
||||||
|
assert(f(2) = 2);
|
||||||
|
end.
|
||||||
|
|
@ -662,7 +662,12 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
}
|
}
|
||||||
en.location = loc;
|
en.location = loc;
|
||||||
if (en.type is delegated_methods dm && dm.proper_methods[0].parameters.Count == 0 && dm.proper_methods[0].ret_type != null)
|
if (en.type is delegated_methods dm && dm.proper_methods[0].parameters.Count == 0 && dm.proper_methods[0].ret_type != null)
|
||||||
AddError(new CanNotConvertTypes(en, dm.proper_methods[0].ret_type, to, loc)); // SSM 18/06/20 #2261
|
{
|
||||||
|
if (to != SystemLibrary.SystemLibrary.object_type)
|
||||||
|
AddError(new CanNotConvertTypes(en, dm.proper_methods[0].ret_type, to, loc)); // SSM 18/06/20 #2261
|
||||||
|
else
|
||||||
|
return en;
|
||||||
|
}
|
||||||
else if (en.type is undefined_type && en is base_function_call bfc)
|
else if (en.type is undefined_type && en is base_function_call bfc)
|
||||||
throw new SimpleSemanticError(loc, "RETURN_TYPE_UNDEFINED_{0}", bfc.function.name);
|
throw new SimpleSemanticError(loc, "RETURN_TYPE_UNDEFINED_{0}", bfc.function.name);
|
||||||
else AddError(new CanNotConvertTypes(en, en.type, to, loc));
|
else AddError(new CanNotConvertTypes(en, en.type, to, loc));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue