Hi,

Well, who writes this kind of code?

Even Dymola complains when you check Test.A:
Check of Test.A:
Error: Recursion limit reached in instantiation of class A.
Probably caused by mutually dependent classes.
  Modelica Text: line 2
  Context: Test.A
ERROR: 1 error was found

If you check Test.B, Dymola goes into an infinite loop
and you need to kill it.

Of course, we should check if extends reaches the
same class and fail instead of going into stack
overflow. I think this model should fail even if
you could handle it via fixpoint.

Cheers,
Adrian Pop/


On 2010-11-17 08:43, Christoph Höger wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

the following example produces a stack overflow in omc 1.5.0.svn.r5700-1.deb

package Test
     class A
         extends B;
         Real x;
         class B
             extends A;
             Real y; // double definition?
             B.B b; // This would not be needed for stack overflow, but
should be correct too
         end B;
     end A;
end Test;

I am not quite sure, why the extension from inner classes is even
allowed (maybe for some fancy type constructs), but the specification is
quite clear on that point. This is a little bit complicated, but from my
POV it should work that way:

- - when B is looked up from "extends B" in A, the "partially flattened"
environment of A is used in B which yields scope(B) = { 'B' = Test.A.B,
'x' = Real, y = 'Real', b = 'Test.A.B' }

- - when B is looked up itself, the above scope is handed down, which
_might_ result in a "double definition" error for y but at least should
succeed in type creation.

Basically the problem arises with circular inheritance, which would in
general require a fixed point analysis. But since the specification
simply states that the type names in extends clauses are looked up
ignoring all other extends clauses, it should work.

best regards,

Christoph

- --

Christoph Höger

Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin

Tel.: +49 (30) 314-24890
E-Mail: [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkzjh5UACgkQhMBO4cVSGS+/PgCfXxfL5Im0XUHa83vdhPSmhsm7
r7MAn2l00xtlIODbot76hCs9/va7vmH9
=jNtX
-----END PGP SIGNATURE-----

Reply via email to