Opened 6 years ago

Last modified 3 years ago

#5474 new defect

[NF] Lookup of inner class fails — at Initial Version

Reported by: Adrian Pop Owned by: Per Östlund
Priority: high Milestone:
Component: New Instantiation Version:
Keywords: Cc:

Description

Trying to instantiate the inner model P fails with:

"C:/home/adrpo33/dev/OpenModelica/OMCompiler/Compiler/NFFrontEnd/NFLookup.mo:870:9-870:101:writable] Error: Internal error NFLookup.generateInner got top node with missing cache
[C:/home/adrpo33/dev/OpenModelica/OMCompiler/Compiler/NFFrontEnd/NFInst.mo:2318:9-2318:91:writable] Error: Internal error NFInst.instComponentExpressions got invalid component
Error: Class M.P not found in scope <top>.
"

Script to reproduce:

loadModel(Modelica); getErrorString();
loadString("
class M
  extends .Modelica.Mechanics.MultiBody.Joints.FreeMotionScalarInit;
  class P
    parameter Real x;
  end P;
end M;");  getErrorString();
instantiateModel(M.P); getErrorString();

The problem is that the lookup is done before initialization of top scope cache for inners:

  // Look up the class to instantiate and mark it as the root class.
  cls := Lookup.lookupClassName(classPath, top, Absyn.dummyInfo, checkAccessViolations = false);
  cls := InstNode.setNodeType(InstNodeType.ROOT_CLASS(InstNode.EMPTY_NODE()), cls);

  // Initialize the storage for automatically generated inner elements.
  top := InstNode.setInnerOuterCache(top, CachedData.TOP_SCOPE(NodeTree.new(), cls));

Change History (0)

Note: See TracTickets for help on using tickets.