Skip to content

Property & indexer access not fully updated for ref get accessors #1371

@Nigel-Ecma

Description

@Nigel-Ecma

In §12.2.2 we have:

  • The value of a property access expression is obtained by invoking the get accessor of the property. If the property has no get accessor, a compile-time error occurs. Otherwise, a function member invocation (§12.6.6) is performed, and the result of the invocation becomes the value of the property access expression.
  • The value of an indexer access expression is obtained by invoking the get accessor of the indexer. If the indexer has no get accessor, a compile-time error occurs. Otherwise, a function member invocation (§12.6.6) is performed with the argument list associated with the indexer access expression, and the result of the invocation becomes the value of the indexer access expression.

Both of these do not allow for a property or indexer with a ref get accessor – in such a case a compile-time error does not occur, a value is the result, etc.

Are ref get accessors classified as something other than property/indexer accesses somewhere?

Property access comes under member_reference, indexer under element_access, do these handle ref get and correctly classify the expression (§12.2), indeed does classification handle ref valued expressions correctly?

Then there is setting a property or indexer element (§12.21.2), is ref get handled correctly in these cases?

Above questions are not claimed to be exhaustive.

The above observations come from adding support for Index and Range (#1369, draft at time of writing) which has added text such as (§12.8.12.3 Indexer access in #1369):

  • Using the best indexer determined at binding-time:
    • If the indexer access is the target of an assignment, the set accessor or ref get accessor is invoked to assign a new value (§12.21.2).
    • In all other cases, the get accessor or ref get accesor is invoked to obtain the current value (§12.2.2).

An ancient (2018 ;-)) issue was raised in csharplang regarding ref get properties, transferred here as #295 years ago (2021 ;-)), and has no milestone…

This surely needs to be sorted for v8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    meeting: discussThis issue should be discussed at the next TC49-TG2 meetingmeeting: priorityReview before meeting. Merge, merge with issues, or reject at the next TC49-TC2 meeting

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions