This commit is contained in:
Бондарев Иван 2020-05-24 20:23:46 +02:00
parent 02f150a99a
commit e8152824ed
3 changed files with 42 additions and 0 deletions

29
TestSuite/lambdas7.pas Normal file
View file

@ -0,0 +1,29 @@
type
TBase<T> = abstract class
procedure p1<T2>(f: T->T2);
begin
assert(f(default(T)).ToString() = 'abc');
end;
end;
TErr = class(TBase<byte>) // обязательно наследовать от TBase
procedure p2;
begin
var o: TBase<byte> := new TErr;
o.p1(function(b: byte)->
begin
Result := 'abc';
var s: string := Result;
var a: byte := b;
end);
end;
end;
begin
var o := new TErr;
o.p2;
end.

View file

@ -107,6 +107,11 @@ namespace TreeConverter.LambdaExpressions
converted = syntaxTreeVisitor.convert_typed_expression_to_function_call(converted as typed_expression);
}
resultExpressionsTypes.Add(new Tuple<type_node, expression, expression_node>(converted.type, from, converted));
var si_list = syntaxTreeVisitor.context.find(RESULT_KEY_WORD);
if (si_list != null && si_list.Count > 0 && si_list[0].sym_info == null)
{
si_list[0].sym_info = new local_variable(RESULT_KEY_WORD, converted.type, syntaxTreeVisitor.context.top_function, null);
}
}
}

View file

@ -1878,6 +1878,14 @@ namespace PascalABCCompiler.TreeRealization
{
foreach (SymbolInfo si in start)
{
if (si.sym_info == null)
{
if (rez_start == null)
rez_start = new List<SymbolInfo>();
rez_start.Add(si);
continue;
}
// Бурмистров Артем 13.06.19 begin
// Поправил странное поведение для локальных переменных, у которых не generic тип
// Исправление для #1993