Skip to content

Commit 2372f3c

Browse files
committed
#2757 Fix the types set when simplifying reductions
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21780 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0d8f725 commit 2372f3c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Compiler/FrontEnd/ExpressionSimplify.mo

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ algorithm
11291129
tp1 = Expression.liftArrayLeft(tp1,DAE.DIM_INTEGER(dim));
11301130
e = DAE.ARRAY(tp1,sc,es);
11311131
e = Expression.makePureBuiltinCall("sum",{e},tp2);
1132-
// print("Matrix sum: " +& boolString(sc) +& ExpressionDump.typeString(tp1) +& " " +& ExpressionDump.printExpStr(e) +& "\n");
1132+
// print("Matrix sum: " +& boolString(sc) +& Types.unparseType(tp1) +& " " +& ExpressionDump.printExpStr(e) +& "\n");
11331133
then e;
11341134
// Then try array concatenation
11351135
case DAE.CALL(path=Absyn.IDENT("sum"),expLst={DAE.ARRAY(array=es,ty=tp1,scalar=false)},attr=DAE.CALL_ATTR(ty=tp2))
@@ -1143,7 +1143,7 @@ algorithm
11431143
tp1 = Expression.liftArrayLeft(tp1,DAE.DIM_INTEGER(dim));
11441144
e = DAE.ARRAY(tp1,sc,es);
11451145
e = Expression.makePureBuiltinCall("sum",{e},tp2);
1146-
// print("Array sum: " +& boolString(sc) +& ExpressionDump.typeString(tp1) +& " " +& ExpressionDump.printExpStr(e) +& "\n");
1146+
// print("Array sum: " +& boolString(sc) +& Types.unparseType(tp1) +& " " +& ExpressionDump.printExpStr(e) +& "\n");
11471147
then e;
11481148
// Try to reduce the number of dimensions
11491149
case DAE.CALL(path=Absyn.IDENT("sum"),expLst={DAE.ARRAY(array={e},scalar=false)},attr=DAE.CALL_ATTR(ty=tp2))
@@ -5046,13 +5046,15 @@ algorithm
50465046
local
50475047
Values.Value val;
50485048
DAE.Exp arr_exp,foldExp;
5049-
DAE.Type aty;
5049+
DAE.Type aty,ty2;
50505050
list<DAE.Exp> exps;
50515051

50525052
case (Absyn.IDENT("array"),_,_,_,_,_,_)
50535053
equation
5054-
aty = Types.unliftArray(ty);
5055-
then Expression.makeScalarArray(inExps, aty);
5054+
aty = Types.unliftArray(Types.expTypetoTypesType(ty));
5055+
ty2 = Types.liftArray(aty, DAE.DIM_INTEGER(listLength(inExps))); // The size can be unknown before the reduction...
5056+
exp = Expression.makeArray(inExps, ty2, not Types.isArray(aty,{}));
5057+
then exp;
50565058

50575059
case (_,_,_,_,_,{},SOME(val)) then ValuesUtil.valueExp(val);
50585060
case (_,_,_,_,_,{},NONE()) then fail();

Compiler/FrontEnd/InstSection.mo

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,7 @@ algorithm
13481348
info = DAEUtil.getElementSourceFileInfo(source);
13491349
Types.typeErrorSanityCheck(t1_str, t2_str, info);
13501350
Error.addSourceMessage(Error.EQUATION_TYPE_MISMATCH_ERROR, {s1,s2}, info);
1351-
Debug.fprintln(Flags.FAILTRACE, "- InstSection.instEqEquation failed with type mismatch in equation: " +& s1 +& " tys: " +& s2);
1352-
then
1353-
fail();
1351+
then fail();
13541352
end matchcontinue;
13551353
end instEqEquation;
13561354

SimulationRuntime/c/util/omc_msvc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ extern "C" {
3636

3737
#include <math.h> /* Make sure we try to get INFINITY and NAN from the system. They are way cooler */
3838

39+
#ifndef NaN
40+
#define NaN NAN
41+
#endif
42+
3943
union MSVC_FLOAT_HACK
4044
{
4145
unsigned char Bytes[4];

0 commit comments

Comments
 (0)