This commit is contained in:
Ivan Bondarev 2023-07-02 12:27:07 +02:00
parent 35381d6778
commit 0d85e872d3
2 changed files with 38 additions and 1 deletions

28
TestSuite/yield7.pas Normal file
View file

@ -0,0 +1,28 @@
type
// Обязательно шаблон
//Ошибка: Данная конструкция не поддерживается текущей версией компилятора
t1<T> = sealed class
// Обязательно static
static procedure p1 := exit;
function f1: sequence of byte;
begin
// Если расскомментировать - не воспроизводится
// t1&<T>.
p1;
// Обязательно yield
yield 1;
end;
end;
begin
var t := new t1<integer>;
var j := 0;
foreach var i in t.f1 do
begin
j := i;
end;
assert(j = 1);
end.

View file

@ -20424,7 +20424,16 @@ namespace PascalABCCompiler.TreeConverter
public override void visit(SyntaxTree.template_type_name node)
{
throw new NotSupportedError(get_location(node));
//throw new NotSupportedError(get_location(node));
ident_with_templateparams id = new ident_with_templateparams();
if (node.name.IndexOf('`') != -1 )
id.name = new ident(node.name.Substring(0, node.name.IndexOf('`')), node.source_context);
else
id.name = new ident(node.name, node.source_context);
id.template_params = new template_param_list();
for (int i = 0; i < node.template_args.Count; i++)
id.template_params.Add(new named_type_reference(node.template_args[0] as SyntaxTree.ident, node.template_args[i].source_context));
id.visit(this);
}
public override void visit(SyntaxTree.default_operator _default_operator)