Skip to content

Commit

Permalink
Fix for #2124:
Browse files Browse the repository at this point in the history
- Reverse the iterators in reductions so we evaluate them in the correct order.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15608 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Mar 21, 2013
1 parent e404c0b commit 49de141
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Compiler/FrontEnd/Static.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1203,11 +1203,13 @@ algorithm
DAE.Properties props;
list<DAE.Type> restTupleTypes;
DAE.TypeSource tsrc;
Absyn.ForIterators iters;

case (cache,env,fn,exp,_,_,st,doVect,pre,_)
case (cache,env,fn,exp,iters,_,st,doVect,pre,_)
equation
env_1 = Env.openScope(env, SCode.NOT_ENCAPSULATED(), SOME(Env.forIterScopeName), NONE());
(cache,env_1,reductionIters,dims,iterconst,hasGuardExp,st) = elabCallReductionIterators(cache, env_1, iterators, impl, st, doVect, pre, info);
iters = listReverse(iters);
(cache,env_1,reductionIters,dims,iterconst,hasGuardExp,st) = elabCallReductionIterators(cache, env_1, iters, impl, st, doVect, pre, info);
dims = listReverse(dims);
// print("elabReductionExp: " +& Dump.printExpStr(exp) +& "\n");
(cache,exp_1,DAE.PROP(expty, expconst),st) = elabExp(cache, env_1, exp, impl, st, doVect, pre, info);
Expand All @@ -1224,11 +1226,12 @@ algorithm
(cache,exp_1,prop,st);

// the freaking expression can be a function call returning a tuple!
case (cache,env,fn,exp,_,_,st,doVect,pre,_)
case (cache,env,fn,exp,iters,_,st,doVect,pre,_)
equation
false = Config.acceptMetaModelicaGrammar();
env_1 = Env.openScope(env, SCode.NOT_ENCAPSULATED(), SOME(Env.forIterScopeName), NONE());
(cache,env_1,reductionIters,dims,iterconst,hasGuardExp,st) = elabCallReductionIterators(cache, env_1, iterators, impl, st, doVect, pre, info);
iters = listReverse(iters);
(cache,env_1,reductionIters,dims,iterconst,hasGuardExp,st) = elabCallReductionIterators(cache, env_1, iters, impl, st, doVect, pre, info);
dims = listReverse(dims);
// print("elabReductionExp: " +& Dump.printExpStr(exp) +& "\n");
(cache,exp_1,props,st) = elabExp(cache, env_1, exp, impl, st, doVect, pre, info);
Expand Down

0 comments on commit 49de141

Please sign in to comment.