Skip to content

Commit

Permalink
Merge pull request #2591 from HansOlsson/ResolveNameConflict
Browse files Browse the repository at this point in the history
Clarify scoping for component names

Closes #2547
  • Loading branch information
HansOlsson committed Jun 22, 2020
2 parents f436fad + df2c407 commit 61d42d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions chapters/classes.tex
Expand Up @@ -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}.
Expand Down
18 changes: 18 additions & 0 deletions chapters/scoping.tex
Expand Up @@ -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}

Expand Down

0 comments on commit 61d42d7

Please sign in to comment.