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

Commit

Permalink
Fix for #4521.
Browse files Browse the repository at this point in the history
- Select the first tuple element when a tuple is used as a modifier.
  • Loading branch information
perost authored and OpenModelica-Hudson committed Sep 25, 2017
1 parent b9e79ec commit 79caae6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Compiler/FrontEnd/Expression.mo
Original file line number Diff line number Diff line change
Expand Up @@ -13125,5 +13125,23 @@ algorithm
cont := not res;
end findCallIsInlineAfterIndexReduction;

public function tupleHead
input DAE.Exp exp;
input DAE.Properties prop;
output DAE.Exp outExp;
output DAE.Properties outProp;
algorithm
(outExp, outProp) := match (exp, prop)
local
DAE.Type ty;

case (DAE.Exp.TUPLE(_ :: _), DAE.Properties.PROP_TUPLE())
then (listHead(exp.PR), Types.propTupleFirstProp(prop));
case (_, DAE.Properties.PROP_TUPLE(type_ = DAE.T_TUPLE(types = ty :: _)))
then (DAE.Exp.TSUB(exp, 1, ty), Types.propTupleFirstProp(prop));
else (exp, prop);
end match;
end tupleHead;

annotation(__OpenModelica_Interface="frontend");
end Expression;
3 changes: 3 additions & 0 deletions Compiler/FrontEnd/Mod.mo
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ algorithm
(cache,subs_1) = elabSubmods(cache, env, ih, pre, subs, impl, inModScope, info);
// print("Mod.elabMod: calling elabExp on mod exp: " + Dump.printExpStr(e) + " in env: " + FGraph.printGraphPathStr(env) + "\n");
(cache,e_1,prop,_) = Static.elabExp(cache, env, e, impl, NONE(), Config.splitArrays(), pre, info); // Vectorize only if arrays are expanded
// Modifiers always apply to single components, so if the expression is
// a tuple (i.e. from a function call) select the first tuple element.
(e_1, prop) = Expression.tupleHead(e_1, prop);
(cache, e_1, prop) = Ceval.cevalIfConstant(cache, env, e_1, prop, impl, info);
(e_val, cache) = elabModValue(cache, env, e_1, prop, impl, info);
(cache,e_2) = PrefixUtil.prefixExp(cache, env, ih, e_1, pre)
Expand Down

0 comments on commit 79caae6

Please sign in to comment.