Skip to content

Commit

Permalink
- fixes for bugs: #1946 #1969
Browse files Browse the repository at this point in the history
- do not allow subtype(Tuple, nonTuple)
- do type conversion of Tuple -> DAE.TSUB(Tuple, 1) 
  when the actual type is tuple and the expected type is not.
  also check that the first type of the tuple agrees with the 
  type of the non-tuple.
- added tests for these bugs
  testsuite/flattening/modelica/built-in-functions/AbsIssues.mo
  testsuite/flattening/modelica/built-in-functions/MultiFunctionReturnValueUseOnlyFirst.mo
- let's see how many tests fail :)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14209 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Dec 3, 2012
1 parent da3a85e commit 653a80c
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions Compiler/FrontEnd/Types.mo
Expand Up @@ -1470,22 +1470,7 @@ algorithm
true = subtypeTypelist(type_list1, type_list2, requireRecordNamesEqual);
then
true;

// check of tuple vs. type: i.e. abs(fcallReturningTuple)
// we try subtype of the first tuple element with the other type!
case (DAE.T_TUPLE(tupleType = tp1::_), tp2, _)
equation
false = Config.acceptMetaModelicaGrammar();
true = subtype2(tp1, tp2, requireRecordNamesEqual);
then
true;
case (tp1, DAE.T_TUPLE(tupleType = tp2::_), _)
equation
false = Config.acceptMetaModelicaGrammar();
true = subtype2(tp1, tp2, requireRecordNamesEqual);
then
true;


// Part of MetaModelica extension. KS
case (DAE.T_METALIST(listType = t1),DAE.T_METALIST(listType = t2),_) then subtype(t1,t2);
case (DAE.T_METAARRAY(ty = t1),DAE.T_METAARRAY(ty = t2),_) then subtype(t1,t2);
Expand Down Expand Up @@ -4123,11 +4108,11 @@ algorithm
end matchcontinue;
end unflattenArrayType2;

protected function typeConvert "function: typeConvert
protected function typeConvert
"function: typeConvert
This functions converts the expression in the first argument to
the type specified in the third argument. The current type of the
expression is given in the second argument.

If no type conversion is possible, this function fails."
input DAE.Exp inExp1;
input Type actual;
Expand Down Expand Up @@ -4165,6 +4150,18 @@ algorithm
ClassInf.State st1,st2;
Absyn.Path p1,p2;

// if we expect notTuple and we get Tuple do DAE.TSUB(e, 1)
// we try subtype of the first tuple element with the other type!
case (e, DAE.T_TUPLE(tupleType = ty1::_), ty2, _)
equation
false = Config.acceptMetaModelicaGrammar();
false = isTuple(ty2);
true = subtype(ty1, ty2);
e = DAE.TSUB(e, 1, ty2);
ty = ty2;
then
(e, ty);

// try dims as list T_ARRAY(a::b::c)
case (e,
ty1 as DAE.T_ARRAY(dims = _::_::_),
Expand Down

0 comments on commit 653a80c

Please sign in to comment.