C# 7.3 interface_method_declaration etc. grammar does not allow return by reference #826
Labels
type: bug
The Standard does not describe the language as intended or implemented
Milestone
Describe the bug
In C# 7.3, a method, property, or indexer as a member of an interface should be able to return by (readonly) reference, but the syntactic grammar does not allow this.
§18.4.2, §18.4.3, §18.4.5.
Example
The following should be allowed, but
ref
does not match the syntactic grammar.Expected behavior
In §18.4.2, interface_method_declaration should allow
ref
orref
readonly
before return_type.In §18.4.3, interface_property_declaration should allow
ref
orref
readonly
before type. It is not necessary to explicitly forbid aset
accessor on such a property, because the text already references §15.7.3, which states: "A ref-returning property shall not have aset
accessor."In §18.4.5, interface_indexer_declaration should allow
ref
orref
readonly
before type. It is not necessary to explicitly forbid aset
accessor on such an indexer, because the text already references §15.9, which states: "Aside from these differences, all rules defined in §15.7.3 and §15.7.4 apply to indexer accessors as well as to property accessors."Additional context
In §18.4.4, interface_event_declaration does not allow
ref
, but that is OK, because the type is not the return type of any accessor of the event.Operators cannot be members of interfaces, and they do not allow
ref
in classes and structs either.The text was updated successfully, but these errors were encountered: