Skip to content

Commit

Permalink
Filter more empty modifiers in mergeElementArgs (#11492)
Browse files Browse the repository at this point in the history
- Also filter out empty modifiers in new modifiers in
  InteractiveUtil.mergeElementArgs.
  • Loading branch information
perost committed Nov 2, 2023
1 parent 437041e commit 7f3fc44
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/Script/InteractiveUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ protected
Boolean found;
algorithm
if listEmpty(inOldArgs) then
outArgs := inNewArgs;
outArgs := removeEmptySubMods(inNewArgs);
elseif listEmpty(inNewArgs) then
outArgs := inOldArgs;
else
Expand Down
19 changes: 19 additions & 0 deletions testsuite/openmodelica/interactive-API/setElementModifierValue.mos
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
loadString("
model M
ClasswithReplaceable classwithReplaceable;
Class c;
end M;
");

Expand Down Expand Up @@ -44,46 +45,64 @@ setElementModifierValue(M, classwithReplaceable, $Code((A(fixed))));
getErrorString();
list(M);

setElementModifierValue(M, c, $Code((x(start, each fixed = true))));
getErrorString();
list(M);

// Result:
// true
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"A\"));
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"B\"));
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(testClass = 12));
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"));
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), A = 1, B = 2);
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), final A, B = 2);
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), A(fixed = true), B = 2);
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), B = 2);
// Class c;
// end M;"
// true
// ""
// "model M
// ClasswithReplaceable classwithReplaceable(otherClass(redeclare ClassB testClass \"C\"), B = 2);
// Class c(x(each fixed = true));
// end M;"
// endResult

0 comments on commit 7f3fc44

Please sign in to comment.