Skip to content

Commit af365cf

Browse files
authored
Fix CevalScriptBackend.moveElementArgInfo (#13308)
- Add missing `else` case to `moveElementArgInfo` to handle comments.
1 parent dc6a7dc commit af365cf

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

OMCompiler/Compiler/Script/CevalScriptBackend.mo

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5566,14 +5566,7 @@ protected function moveAnnotationInfo
55665566
input String dstPath;
55675567
output Absyn.Annotation outAnnotation = inAnnotation;
55685568
algorithm
5569-
_ := match outAnnotation
5570-
case Absyn.ANNOTATION()
5571-
algorithm
5572-
outAnnotation.elementArgs := list(moveElementArgInfo(e, dstPath)
5573-
for e in outAnnotation.elementArgs);
5574-
then
5575-
();
5576-
end match;
5569+
outAnnotation.elementArgs := list(moveElementArgInfo(e, dstPath) for e in outAnnotation.elementArgs);
55775570
end moveAnnotationInfo;
55785571

55795572
protected function moveElementItemInfo
@@ -5633,6 +5626,7 @@ algorithm
56335626
then
56345627
();
56355628

5629+
else ();
56365630
end match;
56375631
end moveElementArgInfo;
56385632

@@ -5788,6 +5782,7 @@ algorithm
57885782
then
57895783
();
57905784

5785+
else ();
57915786
end match;
57925787
end moveElementSpecInfo;
57935788

@@ -5811,29 +5806,15 @@ protected function moveComponentInfo
58115806
input String dstPath;
58125807
output Absyn.Component outComponent = inComponent;
58135808
algorithm
5814-
_ := match outComponent
5815-
case Absyn.COMPONENT()
5816-
algorithm
5817-
outComponent.modification :=
5818-
moveModificationInfo(outComponent.modification, dstPath);
5819-
then
5820-
();
5821-
end match;
5809+
outComponent.modification := moveModificationInfo(outComponent.modification, dstPath);
58225810
end moveComponentInfo;
58235811

58245812
protected function moveExternalDeclInfo
58255813
input Absyn.ExternalDecl inExtDecl;
58265814
input String dstPath;
58275815
output Absyn.ExternalDecl outExtDecl = inExtDecl;
58285816
algorithm
5829-
_ := match outExtDecl
5830-
case Absyn.EXTERNALDECL()
5831-
algorithm
5832-
outExtDecl.annotation_ :=
5833-
moveAnnotationOptInfo(outExtDecl.annotation_, dstPath);
5834-
then
5835-
();
5836-
end match;
5817+
outExtDecl.annotation_ := moveAnnotationOptInfo(outExtDecl.annotation_, dstPath);
58375818
end moveExternalDeclInfo;
58385819

58395820
protected function buildModel "translates and builds the model by running compiler script on the generated makefile"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// name: CopyClass6
2+
// keywords:
3+
// status: correct
4+
// cflags: -d=newInst
5+
//
6+
//
7+
8+
loadString("
9+
model M
10+
Real x annotation(
11+
// comment
12+
Placement(visible = true));
13+
end M;
14+
");
15+
16+
copyClass(M, "M2");
17+
getErrorString();
18+
list(M2);
19+
20+
// Result:
21+
// true
22+
// true
23+
// ""
24+
// "model M2
25+
// Real x annotation(
26+
// // comment
27+
// Placement(visible = true));
28+
// end M2;"
29+
// endResult

testsuite/openmodelica/interactive-API/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CopyClass2.mos \
2929
CopyClass3.mos \
3030
CopyClass4.mos \
3131
CopyClass5.mos \
32+
CopyClass6.mos \
3233
CopyClassInvalid1.mos \
3334
CopyClassRedeclare1.mos \
3435
DefaultComponentName.mos \

0 commit comments

Comments
 (0)