This commit is contained in:
Ivan Bondarev 2024-03-31 11:47:31 +02:00
parent 1609eddc9d
commit e948a54bf4
3 changed files with 39 additions and 5 deletions

12
TestSuite/tuple_var2.pas Normal file
View file

@ -0,0 +1,12 @@
type c1 = class end;
begin
// OK
var (a,b) := |new object, new object|;
//Ошибка: Ожидался кортеж или последовательность
var (c,d) := |new c1, new c1|;
assert(c <> nil);
assert(d <> nil);
assert(c <> d);
end.

View file

@ -44,7 +44,15 @@ namespace PascalABCCompiler.TreeConverter
var t = ConvertSemanticTypeNodeToNETType(expr.type);
if (t == null)
AddError(expr.location, "TUPLE_OR_SEQUENCE_EXPECTED");
{
bool bb;
type_node elem_type = null;
var b = FindIEnumerableElementType(expr.type, ref elem_type, out bb);
if (!b)
AddError(expr.location, "TUPLE_OR_SEQUENCE_EXPECTED");
return;
}
var IsTuple = IsTupleType(t);
var IsSequence = !IsTuple && IsSequenceType(t);

View file

@ -21778,14 +21778,28 @@ namespace PascalABCCompiler.TreeConverter
public override void visit(semantic_ith_element_of ith)
{
var IsSequence = false;
var IsTuple = false;
var sem_ex = convert_strong(ith.id);
sem_ex = convert_if_typed_expression_to_function_call(sem_ex);
var t = ConvertSemanticTypeNodeToNETType(sem_ex.type);
if (t == null)
AddError(sem_ex.location, "TUPLE_OR_SEQUENCE_EXPECTED");
var IsTuple = IsTupleType(t);
var IsSequence = !IsTuple && IsSequenceType(t);
{
bool bb;
type_node elem_type = null;
var b = FindIEnumerableElementType(sem_ex.type, ref elem_type, out bb);
if (b)
IsSequence = true;
else
AddError(sem_ex.location, "TUPLE_OR_SEQUENCE_EXPECTED");
}
if (t != null)
IsTuple = IsTupleType(t);
if (t != null)
IsSequence = !IsTuple && IsSequenceType(t);
if (!IsTuple && !IsSequence)
{