Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit fff1788

Browse files
perostOpenModelica-Hudson
authored andcommitted
Forbid invalid tuple use in nfinst.
1 parent f42e280 commit fff1788

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ algorithm
623623

624624
case Expression.ARRAY() then typeArray(exp.elements, info);
625625
case Expression.RANGE() then typeRange(exp, info);
626-
case Expression.TUPLE() then typeTuple(exp.elements, info);
626+
case Expression.TUPLE() then typeTuple(exp.elements, info, origin);
627627
case Expression.SIZE() then typeSize(exp, info);
628628
case Expression.END() then typeEnd(origin, info);
629629

@@ -1066,6 +1066,7 @@ end typeRange;
10661066
function typeTuple
10671067
input list<Expression> elements;
10681068
input SourceInfo info;
1069+
input ExpOrigin origin;
10691070
output Expression tupleExp;
10701071
output Type tupleType;
10711072
output Variability variability;
@@ -1074,6 +1075,16 @@ protected
10741075
list<Type> tyl;
10751076
list<Variability> valr;
10761077
algorithm
1078+
() := match origin
1079+
case ExpOrigin.LHS() then ();
1080+
else
1081+
algorithm
1082+
Error.addSourceMessage(Error.RHS_TUPLE_EXPRESSION,
1083+
{Expression.toString(Expression.TUPLE(Type.UNKNOWN(), elements))}, info);
1084+
then
1085+
fail();
1086+
end match;
1087+
10771088
(expl, tyl, valr) := typeExpl(elements, info);
10781089
tupleType := Type.TUPLE(tyl, NONE());
10791090
tupleExp := Expression.TUPLE(tupleType, expl);

0 commit comments

Comments
 (0)