Skip to content

Commit

Permalink
Add exception for encapsulated short class lookup, and example demons…
Browse files Browse the repository at this point in the history
…trating it.

Closes modelica#2743
  • Loading branch information
HansOlsson committed Dec 15, 2020
1 parent 5d5a6ed commit 40e51bb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chapters/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,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 \lstineline!encapsulated!, then the modifiers cannot be looked up in the enclosing scope.

\begin{example}
Demonstrating the difference in scopes:
\begin{lstlisting}[language=modelica]
Expand All @@ -617,6 +619,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 40e51bb

Please sign in to comment.