This commit is contained in:
parent
1609eddc9d
commit
e948a54bf4
12
TestSuite/tuple_var2.pas
Normal file
12
TestSuite/tuple_var2.pas
Normal 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.
|
||||||
|
|
@ -44,7 +44,15 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
|
|
||||||
var t = ConvertSemanticTypeNodeToNETType(expr.type);
|
var t = ConvertSemanticTypeNodeToNETType(expr.type);
|
||||||
if (t == null)
|
if (t == null)
|
||||||
|
{
|
||||||
|
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");
|
AddError(expr.location, "TUPLE_OR_SEQUENCE_EXPECTED");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var IsTuple = IsTupleType(t);
|
var IsTuple = IsTupleType(t);
|
||||||
var IsSequence = !IsTuple && IsSequenceType(t);
|
var IsSequence = !IsTuple && IsSequenceType(t);
|
||||||
|
|
|
||||||
|
|
@ -21778,14 +21778,28 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
|
|
||||||
public override void visit(semantic_ith_element_of ith)
|
public override void visit(semantic_ith_element_of ith)
|
||||||
{
|
{
|
||||||
|
var IsSequence = false;
|
||||||
|
var IsTuple = false;
|
||||||
var sem_ex = convert_strong(ith.id);
|
var sem_ex = convert_strong(ith.id);
|
||||||
sem_ex = convert_if_typed_expression_to_function_call(sem_ex);
|
sem_ex = convert_if_typed_expression_to_function_call(sem_ex);
|
||||||
var t = ConvertSemanticTypeNodeToNETType(sem_ex.type);
|
var t = ConvertSemanticTypeNodeToNETType(sem_ex.type);
|
||||||
if (t == null)
|
if (t == null)
|
||||||
|
{
|
||||||
|
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");
|
AddError(sem_ex.location, "TUPLE_OR_SEQUENCE_EXPECTED");
|
||||||
|
|
||||||
var IsTuple = IsTupleType(t);
|
}
|
||||||
var IsSequence = !IsTuple && IsSequenceType(t);
|
|
||||||
|
if (t != null)
|
||||||
|
IsTuple = IsTupleType(t);
|
||||||
|
|
||||||
|
if (t != null)
|
||||||
|
IsSequence = !IsTuple && IsSequenceType(t);
|
||||||
|
|
||||||
if (!IsTuple && !IsSequence)
|
if (!IsTuple && !IsSequence)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue