-
Notifications
You must be signed in to change notification settings - Fork 43
Description
How should scoping be done when a name of a component conflicts with the name used in a type specification? Consider the following example.
package SameName
model A
Real x;
equation
x = time;
end A;
end SameName;
model B
SameName.A SameName;
Real x;
equation
x = SameName.x;
end B;
Should it give an error or should a compiler find the correct definition for SameName when resolving the type of B.SameName?
What if the conflict is not in the same component but in different?
model C
SameName.A x;
Real SameName;
equation
x.x = SameName;
end C;
What if the order of the declaration of x and SameName swapped?
model D
Real SameName;
SameName.A x;
equation
x.x = SameName;
end D;
To me, it looks like in model B there is a cyclic definition of the component SameName. We are supposed to resolve SameName.A in the scope of B, and looking up SameName we would find B.SameName. I tried it in different tools and got different results. Some tools find the package SameName others fail with not very clear messages. Trying to improve on the unclear messages, I find that I cannot just screen for cyclic definitions because then I get into problems like models C and D where the result is different depending on the order of declarations, which should not happen.
There was a similar issue #1170, which resulted in the change to the specification in Section 4.2 saying:
"A component shall not have the same name as its type specifier."
But it looks like the case when only the first name in the type specifier is the same as the component's name manages to sneak around that rule. Also it does not cover the cases of models C and D.