Skip to content

Commit

Permalink
Add exception for encapsulated short class lookup (modelica#2759)
Browse files Browse the repository at this point in the history
* Add exception for encapsulated short class lookup, and example demonstrating it.
Closes modelica#2743
  • Loading branch information
HansOlsson committed Dec 16, 2020
1 parent db20782 commit abab745
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chapters/classes.tex
Expand Up @@ -600,6 +600,8 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
end IDENT1;
\end{lstlisting}

An exception to the above is that if the short class definition is declared as \lstinline!encapsulated!, then the modifiers follow the rules for encapsulated classes and cannot be looked up in the enclosing scope.

\begin{example}
Demonstrating the difference in scopes:
\begin{lstlisting}[language=modelica]
Expand All @@ -616,6 +618,8 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
// Gives the singular equation R=R, since the right-hand side R
// is searched for in LoadError and found in its base-class Resistor.
end LoadError constrainedby TwoPin;
encapsulated model Load2=.Resistor(R=2); // Ok
encapsulated model LoadR=.Resistor(R=R); // Illegal
Load a,b,c;
ConstantSource ...;
...
Expand Down

0 comments on commit abab745

Please sign in to comment.