diff --git a/chapters/classes.tex b/chapters/classes.tex index 9e8e4578b..dce7ae11f 100644 --- a/chapters/classes.tex +++ b/chapters/classes.tex @@ -54,8 +54,7 @@ \section{Access Control -- Public and Protected Elements}\doublelabel{access-con \section{Double Declaration not Allowed}\doublelabel{double-declaration-not-allowed} The name of a declared element shall not have the same name as any other -element in its partially flattened enclosing class. A component shall -not have the same name as its type specifier. However, the internal +element in its partially flattened enclosing class. However, the internal flattening of a class can in some cases be interpreted as having two elements with the same name; these cases are described in \autoref{simultaneous-inner-outer-declarations}, and \autoref{redeclaration}. diff --git a/chapters/scoping.tex b/chapters/scoping.tex index 84c4266ce..980049575 100644 --- a/chapters/scoping.tex +++ b/chapters/scoping.tex @@ -135,6 +135,24 @@ \subsection{Composite Name Lookup}\doublelabel{composite-name-lookup} \autoref{redeclaration} for further explanations regarding looking inside partial packages. \end{nonnormative} +\begin{example} +Components and classes are part of the same name-space and thus a component cannot +have the same name as its class or the first part of the class-name as that +would prevent lookup of the class name. +\begin{lstlisting}[language=modelica] +model A + M M; // Illegal, component 'M' prevents finding class 'M' + P.Q P; // Illegal, component 'P' prevents finding package 'P' + .R R; // Legal, see next section + S.Q Q; // Legal + + Y a; // Illegal, component 'Y' (below) prevents finding class 'Y' + Y.X b; // Illegal, component 'Y' (below) prevents finding package 'Y' + .Y c; // Legal, see next section + Real Y; +end A; +\end{lstlisting} +\end{example} \subsection{Global Name Lookup}\doublelabel{global-name-lookup}