C# 7 §13.6.2 ref readonly
in local_variable_initializer
#828
Labels
type: bug
The Standard does not describe the language as intended or implemented
Milestone
Describe the bug
In the C# 7 draft, §13.6.2 (Statements / Declaration statements / Local variable declarations) specifies the following restriction for "implicitly typed local variable declaration":
However,
ref readonly
at the start of a local_variable_initializer is not allowed by the grammar and not allowed by Roslyn either. The grammar allowsref readonly
in local_variable_declaration in front of local_variable_type, but not in front of an expression.Example
The text of the draft gives the impression that
ref readonly i
is valid in the following. It is not.Expected behavior
Say just "optionally preceded by
ref
" and don't mentionref readonly
.Additional context
Declaring and using ref readonly locals in the C# 7.2 proposal shows the initialization
ref readonly var r1 = ref M1();
without usingref readonly
in the initializer.The text was updated successfully, but these errors were encountered: