Opened 15 years ago

Closed 10 years ago

Last modified 10 years ago

#1184 closed defect (fixed)

Problem with name lookup when using classDirectory()

Reported by: Jan Brugård Owned by: Jan Brugård
Priority: critical Milestone:
Component: Backend Version:
Keywords: Cc: Jan Brugård

Description

Consider the following package:

package Utilities "Utility classes usually not directly utilized by the user"
  extends Icons.Package;
  constant String RootDir=Modelica.Utilities.Files.fullPathName(classDirectory() + "..");
  package Icons 
    extends Package;
    partial class Package "Icon for a package class"
      annotation(Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Rectangle(extent={{-60,100},{100,-60}}, lineColor={0,0,255}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Polygon(points={{-100,60},{-60,100},{-60,60},{-100,60}}, lineColor={0,0,255}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Polygon(points={{60,-60},{100,-60},{60,-100},{60,-60}}, lineColor={0,0,255}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Rectangle(extent={{-100,60},{60,-100}}, lineColor={0,0,255}, fillColor={215,215,215}, fillPattern=FillPattern.Solid)}));
    end Package;

  end Icons;

end Utilities;

Name lookup of Icons.Package in Utilities fails. However it the declaration is changed to

  extends Utilities.Icons.Package;

or if the declaration of the constant is removed or changed so it does not use classDirectory(), the lookup works.

The function classDirectory() is not standardized, but nevertheless name lookup of the icon should not be affected!

Change History (4)

comment:1 by Martin Sjölund, 15 years ago

Seems to have been fixed along with the other changes made to instantiation of extends. Testcase mofiles/Extends7.mo has been added for regression testing.

comment:2 by Henrik Tidefelt, 10 years ago

Cc: brugard, → brugard
Component: Backend
Resolution: fixed
Status: closedreopened

The expression in the ticket description,

classDirectory() + ".."

assumes that classDirectory() yields a string that ends with a directory separator. The current implementation yields a string without trailing separator.

Besides, some commercial libraries use classDirectory() under the assumption that the resulting directory name is absolute, contrary to the current implementation.

Finally, the test Extends7.mo (currently in flattening/modelica/extends) does not even mention classDirectory, so it is not a relevant test for this ticket.

comment:3 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: reopenedclosed

Open a new ticket, do not resurrect 4-year old tickets from the dead: this was not a ticket to support classDirectory(); it was to not fail in some cases for extends.

comment:4 by Henrik Tidefelt, 10 years ago

Created #2731 concerning the support of classDirectory().

Note: See TracTickets for help on using tickets.