Skip to content

[C# language specification 7th edition] Incorrect rule for definite-assignment state for || expressions #1070

@fmdkara

Description

@fmdkara

I downloaded the C# language specification 7th edition via https://ecma-international.org/publications-and-standards/standards/ecma-334/. In chapter 9.4.4.27 about definite-assignment state of || expressions, it was written

The definite-assignment state of v before expr_second is definitely assigned if and only if the state of
v after expr_first is either definitely assigned or “definitely assigned after true expression”.
Otherwise, it is not definitely assigned.

However, i believe that is incorrect, the correct one should be

The definite-assignment state of v before expr_second is definitely assigned if and only if the state of
v after expr_first is either definitely assigned or “definitely assigned after false expression”.
Otherwise, it is not definitely assigned.

Because if the former is correct, then v can be definitely-assigned when it shouldn't be, consider the following situation:

  1. The definite-assignment state of v after expr_first is definitely assigned after true expression
  2. expr_first is false
  3. expr_second is evaluated and the definite-assignment state of v before expr_second is definitely-assigned, however because number 1 and 2, then v is not actually assigned.

From the reason above, i believe that the former is incorrect and the latter is the correct one

Metadata

Metadata

Assignees

Labels

meeting: discussThis issue should be discussed at the next TC49-TG2 meeting

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions