dotnet / dotnet/csharpstandard
15.11.2: Edit introduces contradiction
- Dominant language
- C#
- Stars
- 815
- Forks
- 99
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 16
Description
The second bullet of this clause has added "or a type derived from it":
> • A unary `++` or `--` operator shall take a single parameter of type `T` or `T?` and shall return that same type or a type derived from it.
This contradicts $13.8.6 which states:
> The operand of a prefix increment or decrement operation shall be an expression classified as a variable, a property access, or an indexer access. The result of the operation is a value of the same type as the operand.
_Note this isn't saying that the type of the variable and the type of the operator match, text later in that clause allows for value of variable type -> convert to value of operator type -> operation producing value of operator type -> convert to value of variable type._
_Note this restriction does not appear to apply to other operators, e.g. unary or binary `+` can take and return different types._
So we have a contradiction, which is right? I'll go with the Standard being right unless someone presents the contra-case.
Proposal: reject the addition of "or a type derived from it" reverting to the Standard text.
Contributor guide
Assessment
This issue has not been assessed yet.