Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 29e8121

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Make getAnnotationNamedModifiers not return bad data
If the annotation does not exist, use the error buffer to return the message instead of saying an annotation with a weird name exists.
1 parent 702501a commit 29e8121

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Compiler/Script/CevalScriptBackend.mo

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ algorithm
756756
list<SimpleModelicaParser.ParseTree> parseTree1, parseTree2;
757757
list<tuple<Diff, list<Token>>> diffs;
758758
list<tuple<Diff, list<SimpleModelicaParser.ParseTree>>> treeDiffs;
759+
SourceInfo info;
759760

760761
case (cache,_,"setClassComment",{Values.CODE(Absyn.C_TYPENAME(path)),Values.STRING(str)},st as GlobalScript.SYMBOLTABLE(ast=p),_)
761762
equation
@@ -2039,9 +2040,9 @@ algorithm
20392040

20402041
case (cache,_,"getAnnotationNamedModifiers",{Values.CODE(Absyn.C_TYPENAME(classpath)),Values.STRING(annotationname)},st as GlobalScript.SYMBOLTABLE(ast=p),_)
20412042
equation
2042-
Absyn.CLASS(_,_,_,_,_,cdef,_) =Interactive.getPathedClassInProgram(classpath,p);
2043+
Absyn.CLASS(body=cdef,info=info) =Interactive.getPathedClassInProgram(classpath,p);
20432044
annlst= getAnnotationList(cdef);
2044-
modifiernamelst=getElementArgsModifiers(annlst,annotationname);
2045+
modifiernamelst=getElementArgsModifiers(annlst,annotationname,Absyn.pathString(classpath),info);
20452046
v1 = ValuesUtil.makeArray(List.map(modifiernamelst, ValuesUtil.makeString));
20462047
then
20472048
(cache,v1,st);
@@ -7854,6 +7855,8 @@ function getElementArgsModifiers
78547855
"@author arun Helper function which parses list of elementargs,annotationname returns the list of modifiers name in the annotation"
78557856
input list<Absyn.ElementArg> inargs;
78567857
input String instring;
7858+
input String inClass;
7859+
input SourceInfo info;
78577860
output list<String> outstring;
78587861
algorithm
78597862
outstring:=match(inargs,instring)
@@ -7873,9 +7876,12 @@ algorithm
78737876

78747877
case((_::eltarglst),name1)
78757878
then
7876-
getElementArgsModifiers(eltarglst,name1);
7879+
getElementArgsModifiers(eltarglst,name1,inClass,info);
78777880

7878-
case({},_) then {"The searched annotation name not found"};
7881+
case ({},_)
7882+
algorithm
7883+
Error.addSourceMessage(Error.CLASS_ANNOTATION_DOES_NOT_EXIST, {instring, inClass}, info);
7884+
then {};
78797885
end match;
78807886
end getElementArgsModifiers;
78817887

0 commit comments

Comments
 (0)