diff --git a/OMCompiler/Compiler/Script/InteractiveUtil.mo b/OMCompiler/Compiler/Script/InteractiveUtil.mo index 3edf9b1145f..4279df39345 100644 --- a/OMCompiler/Compiler/Script/InteractiveUtil.mo +++ b/OMCompiler/Compiler/Script/InteractiveUtil.mo @@ -616,10 +616,36 @@ algorithm end if; end for; - outArgs := list(arg for arg guard not AbsynUtil.isEmptySubMod(arg) in outArgs); + outArgs := removeEmptySubMods(outArgs); end if; end mergeElementArgs; +function removeEmptySubMods + input list subMods; + output list outSubMods = {}; +protected + Absyn.Modification mod; +algorithm + for m in subMods loop + () := match m + case Absyn.ElementArg.MODIFICATION(modification = SOME(mod)) + algorithm + mod.elementArgLst := removeEmptySubMods(mod.elementArgLst); + m.modification := if AbsynUtil.isEmptyMod(mod) then NONE() else SOME(mod); + then + (); + + else (); + end match; + + if not AbsynUtil.isEmptySubMod(m) then + outSubMods := m :: outSubMods; + end if; + end for; + + outSubMods := Dangerous.listReverseInPlace(outSubMods); +end removeEmptySubMods; + protected function propagateMod2 input Absyn.Path inComponentName; input list inSubMods; diff --git a/testsuite/openmodelica/interactive-API/setElementModifierValue.mos b/testsuite/openmodelica/interactive-API/setElementModifierValue.mos index c8a9fad5e05..be9f287abaa 100644 --- a/testsuite/openmodelica/interactive-API/setElementModifierValue.mos +++ b/testsuite/openmodelica/interactive-API/setElementModifierValue.mos @@ -36,6 +36,14 @@ setElementModifierValue(M, classwithReplaceable, $Code((final A, B = 2))); getErrorString(); list(M); +setElementModifierValue(M, classwithReplaceable, $Code((A(fixed = true)))); +getErrorString(); +list(M); + +setElementModifierValue(M, classwithReplaceable, $Code((A(fixed)))); +getErrorString(); +list(M); + // Result: // true // true @@ -68,4 +76,14 @@ list(M); // "model M // ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), final A, B = 2); // end M;" +// true +// "" +// "model M +// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), A(fixed = true), B = 2); +// end M;" +// true +// "" +// "model M +// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), B = 2); +// end M;" // endResult