Hierarchical referencing within hierarchy of class objects

In reply to mike_mentor:

I think local scope is the term you all are looking for.

A module and all procedural constructs like tasks/functions/begin/end blocks all create local scope, some of which can be nested. An instance of module tb creates a local scope of which env_inst is a member. Since there is only one instance of tb, you can refer to tb.env_int or explicitly $root.tb.env_inst from anywhere (except inside a package which does not allow any hierarchical references)

task printRefFull();
  $display("Ref full path value = %0d",$root.tb.env_inst.driver1_inst.someint);
endtask

If you have a statement inside a nested local scope (myblock), it can refer upwards to members in the outer scope directly. that is why the $display statements inside myblock work correctly.

The $display statement inside the task printRefPartial does not compile because there is no driver1_inst in the local scope of the task, nor is the a driver_inst inside the local scope of the class driver2. The local scope above the class is the compilation unit, and there is no driver1_inst there either. The fact that driver2 was constructed inside env does not make env an upwards scope to driver2. Objects get constructed dynamically during execution, and the search for identifiers needs to happen during compilation.