I would view this as illegal for the same reason as you indicate Mark.
I'm not sure that I would use the term "rights" in the way that you
did -- I would say exactly that if Outer::x were protected or local. Those
determine access "rights". Here I would say that such "outer" references
are implicitly "static class prefixed" references and as such, it is not
legal to access a non-static member.
Gord.
On 11/17/2011 5:41 PM, Mark Hartoog wrote:
>
> An issue recently came up and I am wondering if other people agree
> with my understanding of the how name resolution works in nested classes.
>
> LRM section 8.22 Class scope resolution operator ::
>
> "Nested classes shall have the same access rights as methods do in the
> containing class. They have full access
>
> rights to local and protected methods and properties of the containing
> class. Nested classes have lexically-
>
> scoped, unqualified access to the static properties and methods,
> parameters, and local parameters of
>
> the containing class. They shall not have implicit access to
> non-static properties and methods except through
>
> a handle either passed to it or otherwise accessible by it. There is
> no implicit this handle to the outer class."
>
> Consider this case:
>
> module test;
>
> int x = 1;
>
> class Outer;
>
> int x = 2;
>
> class Inner;
>
> static function int getX();
>
> return x; // is this illegal?
>
> endfunction
>
> endclass
>
> endclass
>
> initial $display(Outer::Inner::getX());
>
> endmodule
>
> My understanding is that this 'x' in Outer::Inner::getX() is an
> illegal attempt to access a non-static outer class field. The field
> 'x' in Outer is lexically visible in the class Inner, but the class
> Inner does not have access rights to the non-static field.
>
> Someone has tried to suggest to me that what the LRM meant is that the
> non-static methods and fields are not visible in the inner class, and
> then the 'x' should bind to the module level variable 'x'.
>
>
> --
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
> believed to be clean.
-- -------------------------------------------------------------------- Gordon Vreugdenhil 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Nov 17 21:09:49 2011
This archive was generated by hypermail 2.1.8 : Thu Nov 17 2011 - 21:09:54 PST