Skip to content

Commit

Permalink
Fix InteractiveUtil.getPathedElementInProgram for builtins (#11131)
Browse files Browse the repository at this point in the history
- Retry the lookup in the builtin environment if the element isn't found
  among the userdefined elements.
  • Loading branch information
perost committed Sep 6, 2023
1 parent db2ff9a commit df135a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion OMCompiler/Compiler/Script/InteractiveUtil.mo
Expand Up @@ -4633,7 +4633,11 @@ public function getPathedElementInProgram
protected
Absyn.Class cls;
algorithm
cls := getClassInProgram(AbsynUtil.pathFirstIdent(path), program);
try
cls := getClassInProgram(AbsynUtil.pathFirstIdent(path), program);
else
cls := getClassInProgram(AbsynUtil.pathFirstIdent(path), FBuiltin.getInitialFunctions());
end try;

if AbsynUtil.pathIsIdent(path) then
// Since the program only stores classes instead of elements we have to
Expand Down
2 changes: 2 additions & 0 deletions testsuite/openmodelica/interactive-API/getClassComment.mos
Expand Up @@ -23,6 +23,7 @@ getClassComment(P.M2);
getClassComment(P.M3);
getClassComment(P.M);
getClassComment(P.ME);
getClassComment(OpenModelica.Scripting.loadFile);

// Result:
// true
Expand All @@ -32,4 +33,5 @@ getClassComment(P.ME);
// "After constraint"
// "M comment"
// "ME comment"
// "load file (*.mo) and merge it with the loaded AST."
// endResult

0 comments on commit df135a6

Please sign in to comment.