5.6.12 Member Access Expressions

A member access expression is used to reference a member of an entity.

 member-access-expression = l-expression NO-WS "." unrestricted-name  
 member-access-expression =/ l-expression line-continuation "." unrestricted-name  

Static semantics. The semantics of a member access expression depend on the binding context.

A member access expression under the default binding context is valid only if one of the following is true:

  • <l-expression> is classified as a variable, a property or a function and one of the following is true:

    • The declared type of <l-expression> is a UDT type or specific class, this type has an accessible member named <unrestricted-name>, <unrestricted-name> either does not specify a type character or specifies a type character whose associated type matches the declared type of the member, and one of the following is true:

      • The member is a variable, property or function. In this case, the member access expression is classified as a variable, property or function, respectively, refers to the member, and has the same declared type as the member.

      • The member is a subroutine. In this case, the member access expression is classified as a subroutine and refers to the member.

    • The declared type of <l-expression> is Object or Variant. In this case, the member access expression is classified as an unbound member and has a declared type of Variant.

  • <l-expression> is classified as an unbound member. In this case, the member access expression is classified as an unbound member and has a declared type of Variant.

  • <l-expression> is classified as a project, this project is either the enclosing project or a referenced project, and one of the following is true:

    • <l-expression> refers to the enclosing project and <unrestricted-name> is either the name of the enclosing project or a referenced project. In this case, the member access expression is classified as a project and refers to the specified project.

    • The project has an accessible procedural module named <unrestricted-name>. In this case, the member access expression is classified as a procedural module and refers to the specified procedural module.

    • The project does not have an accessible procedural module named <unrestricted-name> and exactly one of the procedural modules within the project has an accessible member named <unrestricted-name>, <unrestricted-name> either does not specify a type character or specifies a type character whose associated type matches the declared type of the member, and one of the following is true:

      • The member is a variable, property or function. In this case, the member access expression is classified as a variable, property or function, respectively, refers to the member, and has the same declared type as the member.

      • The member is a subroutine. In this case, the member access expression is classified as a subroutine and refers to the member.

      • The member is a value. In this case, the member access expression is classified as a value with the same declared type as the member.

  • <l-expression> is classified as a procedural module, this procedural module has an accessible member named <unrestricted-name>, <unrestricted-name> either does not specify a type character or specifies a type character whose associated type matches the declared type of the member, and one of the following is true:

    • The member is a variable, property or function. In this case, the member access expression is classified as a variable, property or function, respectively, and has the same declared type as the member.

    • The member is a subroutine. In this case, the member access expression is classified as a subroutine.

    • The member is a value. In this case, the member access expression is classified as a value with the same declared type as the member.

  • <l-expression> is classified as a type, this type is an Enum type, and this type has an enum member named <unrestricted-name>. In this case, the member access expression is classified as a value with the same declared type as the enum member.

    A member access expression under the type binding context is valid only if one of the following is true:

  • <l-expression> is classified as a project, this project is either the enclosing project or a referenced project, and one of the following is true:

    • <l-expression> refers to the enclosing project and <unrestricted-name> is either the name of the enclosing project or a referenced project. In this case, the member access expression is classified as a project and refers to the specified project.

    • The project has an accessible procedural module named <unrestricted-name>. In this case, the member access expression is classified as a procedural module and refers to the specified procedural module.

    • The project has an accessible class module named <unrestricted-name>. In this case, the member access expression is classified as a type and refers to the specified class.

    • The project does not have an accessible module named <unrestricted-name> and exactly one of the procedural modules within the project contains a UDT or Enum definition named <unrestricted-name>. In this case, the member access expression is classified as a type and refers to the specified UDT or enum.

  • <l-expression> is classified as a procedural module or a type referencing a class defined in a class module, and one of the following is true:

    • This module has an accessible UDT or Enum definition named <unrestricted-name>. In this case, the member access expression is classified as a type and refers to the specified UDT or Enum type.

    A member access expression under the procedure pointer binding context is valid only if <l-expression> is classified as a procedural module, this procedural module has an accessible function or subroutine with the same name value as <unrestricted-name>, and <unrestricted-name> either does not specify a type character or specifies a type character whose associated type matches the declared type of the function or subroutine. In this case, the member access expression is classified as a function or subroutine, respectively.