@@ -367,6 +367,51 @@ algorithm
367367 end match;
368368end makeAssignmentsList;
369369
370+ public function checkLHSWritable
371+ "@author: adrpo
372+ check if the parameters on rhs have fixed = false
373+ and fail otherwise"
374+ input list< DAE . Exp > lhs;
375+ input list< DAE . Properties > props;
376+ input DAE . Exp rhs;
377+ input DAE . ElementSource source;
378+ protected
379+ DAE . Type ty;
380+ Integer i = 1 ;
381+ String c, l, r;
382+ algorithm
383+ for p in props loop
384+ _ := matchcontinue p
385+ // variables is fine
386+ case DAE . PROP (constFlag = DAE . C_VAR ()) then ();
387+ // constant
388+ case DAE . PROP (ty, DAE . C_CONST ())
389+ equation
390+ l = stringAppendList({"(" , stringDelimitList(List . map(lhs, ExpressionDump . printExpStr), ", " ), ")" });
391+ r = ExpressionDump . printExpStr(rhs);
392+ Error . addSourceMessage(Error . ASSIGN_CONSTANT_ERROR , {l, r}, ElementSource . getElementSourceFileInfo(source));
393+ fail();
394+ then
395+ ();
396+ // parameters
397+ case DAE . PROP (ty, DAE . C_PARAM ())
398+ equation
399+ if Types . getFixedVarAttributeParameterOrConstant(ty) then
400+ l = stringAppendList({"(" , stringDelimitList(List . map(lhs, ExpressionDump . printExpStr), ", " ), ")" });
401+ r = ExpressionDump . printExpStr(rhs);
402+ c = ExpressionDump . printExpStr(listGet(lhs, i));
403+ Error . addSourceMessage(Error . ASSIGN_PARAM_FIXED_ERROR , {c, l, r}, ElementSource . getElementSourceFileInfo(source));
404+ fail();
405+ end if ;
406+ then
407+ ();
408+ // tuples? TODO! FIXME! can we get tuple here? maybe only for MetaModelica
409+ case DAE . PROP_TUPLE (ty, _) then ();
410+ end matchcontinue;
411+ i := i + 1 ;
412+ end for ;
413+ end checkLHSWritable;
414+
370415public function makeTupleAssignment "This function creates an `DAE.STMT_TUPLE_ASSIGN \' construct, and checks that the
371416 assignment is semantically valid, which means that the component
372417 being assigned is not constant, and that the types match."
@@ -390,6 +435,7 @@ algorithm
390435 list< DAE . Type > lhrtypes, tpl;
391436 list< DAE . TupleConst > clist;
392437 DAE . Type ty;
438+ DAE . Const const;
393439
394440 case (lhs, lprop, rhs, _, _, _)
395441 equation
@@ -416,8 +462,7 @@ algorithm
416462 // a normal prop in rhs that contains a T_TUPLE!
417463 case (expl, lhprops, rhs, DAE . PROP (type_ = ty as DAE . T_TUPLE (types = tpl)), _, _)
418464 equation
419- bvals = List . map(lhprops, Types . propAnyConst);
420- DAE . C_VAR () = List . reduce(bvals, Types . constOr);
465+ checkLHSWritable(expl, lhprops, rhs, source);
421466 lhrtypes = List . map(lhprops, Types . getPropType);
422467 Types . matchTypeTupleCall(rhs, tpl, lhrtypes);
423468 /* Don\'t use new rhs\', since type conversions of
@@ -426,8 +471,7 @@ algorithm
426471 // a tuple in rhs
427472 case (expl, lhprops, rhs, DAE . PROP_TUPLE (type_ = ty as DAE . T_TUPLE (types = tpl), tupleConst = DAE . TUPLE_CONST ()), _, _)
428473 equation
429- bvals = List . map(lhprops, Types . propAnyConst);
430- DAE . C_VAR () = List . reduce(bvals, Types . constOr);
474+ checkLHSWritable(expl, lhprops, rhs, source);
431475 lhrtypes = List . map(lhprops, Types . getPropType);
432476 Types . matchTypeTupleCall(rhs, tpl, lhrtypes);
433477 /* Don\'t use new rhs\', since type conversions of several output args are not clearly defined. */
0 commit comments