Skip to content

Commit

Permalink
Allow invalid variability in relaxed contexts (#10629)
Browse files Browse the repository at this point in the history
Fixes #10602
  • Loading branch information
perost committed Apr 28, 2023
1 parent f19aec0 commit 9b202f8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
5 changes: 4 additions & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFTyping.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,10 @@ algorithm
Prefixes.variabilityString(bind_eff_var)
},
Binding.getInfo(binding));
fail();

if not InstContext.inRelaxed(context) then
fail();
end if;
end if;

// Mark parameters that have a structural cref as binding as also
Expand Down
61 changes: 61 additions & 0 deletions testsuite/openmodelica/instance-API/GetModelInstanceBinding5.mos
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// name: GetModelInstanceBinding5
// keywords:
// status: correct
// cflags: -d=newInst
//
//

loadString("
model M
parameter Real x = time;
end M;
");

getModelInstance(M, prettyPrint = true);
getErrorString();

// Result:
// true
// "{
// \"name\": \"M\",
// \"restriction\": \"model\",
// \"elements\": [
// {
// \"$kind\": \"component\",
// \"name\": \"x\",
// \"type\": \"Real\",
// \"modifiers\": \"time\",
// \"value\": {
// \"binding\": {
// \"$kind\": \"cref\",
// \"parts\": [
// {
// \"name\": \"time\"
// }
// ]
// },
// \"value\": {
// \"$kind\": \"cref\",
// \"parts\": [
// {
// \"name\": \"time\"
// }
// ]
// }
// },
// \"prefixes\": {
// \"variability\": \"parameter\"
// }
// }
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 2,
// \"columnStart\": 3,
// \"lineEnd\": 4,
// \"columnEnd\": 8
// }
// }"
// "[<interactive>:3:5-3:28:writable] Error: Component x of variability parameter has binding 'time' of higher variability continuous.
// "
// endResult
1 change: 1 addition & 0 deletions testsuite/openmodelica/instance-API/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GetModelInstanceBinding1.mos \
GetModelInstanceBinding2.mos \
GetModelInstanceBinding3.mos \
GetModelInstanceBinding4.mos \
GetModelInstanceBinding5.mos \
GetModelInstanceChoices1.mos \
GetModelInstanceChoices2.mos \
GetModelInstanceComment1.mos \
Expand Down

0 comments on commit 9b202f8

Please sign in to comment.