Skip to content

Commit

Permalink
[NF] Update the call type when type casting.
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2956
  • Loading branch information
perost authored and OpenModelica-Hudson committed Mar 1, 2019
1 parent 69a3ec4 commit 2ba9e4b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Compiler/NFFrontEnd/NFCall.mo
Expand Up @@ -850,11 +850,14 @@ uniontype Call
input Type ty;
protected
Call call;
Type cast_ty;
algorithm
Expression.CALL(call = call) := callExp;

callExp := match call
case TYPED_CALL() guard Function.isBuiltin(call.fn)
algorithm
cast_ty := Type.setArrayElementType(call.ty, ty);
then
match Absyn.pathFirstIdent(Function.name(call.fn))
// For 'fill' we can type cast the first argument rather than the
Expand All @@ -863,6 +866,7 @@ uniontype Call
algorithm
call.arguments := Expression.typeCast(listHead(call.arguments), ty) ::
listRest(call.arguments);
call.ty := cast_ty;
then
Expression.CALL(call);

Expand All @@ -871,10 +875,11 @@ uniontype Call
case "diagonal"
algorithm
call.arguments := {Expression.typeCast(listHead(call.arguments), ty)};
call.ty := cast_ty;
then
Expression.CALL(call);

else Expression.CAST(Type.setArrayElementType(call.ty, ty), callExp);
else Expression.CAST(cast_ty, callExp);
end match;

else Expression.CAST(Type.setArrayElementType(typeOf(call), ty), callExp);
Expand Down

0 comments on commit 2ba9e4b

Please sign in to comment.