@@ -739,6 +739,7 @@ algorithm
739739 case (cache,env,ih,mod,pre,csets,ci_state,SCode . EQ_REINIT (cref = cr,expReinit = e2,info = info),initial_,impl,graph)
740740 equation
741741 (cache,SOME ((e1_1 as DAE . CREF (cr_1,t),tprop1,_))) = Static . elabCref(cache,env, cr, impl,false ,pre,info) "reinit statement" ;
742+ checkReinitType(t, cr_1, info);
742743 (cache, e1_1, tprop1) = Ceval . cevalIfConstant(cache, env, e1_1, tprop1, impl, info);
743744 (cache,e2_1,tprop2,_) = Static . elabExp(cache,env, e2, impl,NONE (),true ,pre,info);
744745 (cache, e2_1, tprop2) = Ceval . cevalIfConstant(cache, env, e2_1, tprop2, impl, info);
@@ -852,6 +853,37 @@ algorithm
852853 end matchcontinue;
853854end instEquationCommonWork;
854855
856+ protected function checkReinitType
857+ "Checks that the base type of the given type is Real, otherwise it prints an
858+ error message that the first argument to reinit must be a subtype of Real."
859+ input DAE . Type inType;
860+ input DAE . ComponentRef inCref;
861+ input Absyn . Info inInfo;
862+ algorithm
863+ _ := matchcontinue(inType, inCref, inInfo)
864+ local
865+ DAE . Type ty;
866+ String cref_str;
867+
868+ case (_, _, _)
869+ equation
870+ ty = Types . arrayElementType(inType);
871+ true = Types . isReal(ty);
872+ then
873+ ();
874+
875+ else
876+ equation
877+ cref_str = ComponentReference . printComponentRefStr(inCref);
878+ Error . addSourceMessage(Error . REINIT_MUST_BE_REAL ,
879+ {cref_str}, inInfo);
880+ then
881+ fail();
882+
883+ end matchcontinue;
884+ end checkReinitType;
885+
886+
855887/* protected function checkTupleCallEquation "Check if the two expressions make up a proper tuple function call.
856888Returns the error on failure."
857889 input Absyn.Exp left;
0 commit comments