-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
This issue was discussed in LDM 7/27/2022. It is blocked on #62983 (spec existing grammar and consider impact on implementation).
// foreach:
foreach (scoped R r in c1) { }
foreach (scoped ref int i in c2) { }
// for:
for (scoped R r = s; ; ) { }
for (scoped ref int a = ref b; ; ) { }
// deconstruction:
(scoped R x, scoped R y) = F();
scoped var (x, y) = F(); // probably should disallow
// out var:
F(out scoped R r);
F(out scoped var r);Relates to test plan #59194
To support this, we'd need to expand the grammar to allow modifiers in declaration_expression, for_each_statement, for_statement (see proposal below).
This raises the questions:
- do we want to do this?
- confirm that
scopedwould be the only modifier allowed in those positions. Other declaration modifiers (const,static,readonly,volatile) are already not applicable to local declarations.
declaration_expression
: modifier* type variable_designation // add modifiers
;
for_each_statement
: attribute_list* 'await'? 'foreach' '(' modifier* type identifier_token 'in' expression ')' statement // add modifiers
;
for_each_variable_statement
: attribute_list* 'await'? 'foreach' '(' expression 'in' expression ')' statement // covered by declaration_expression
;
fixed_statement
: attribute_list* 'fixed' '(' variable_declaration ')' statement // probably leave untouched
;
for_statement
: attribute_list* 'for' '(' (modifier* variable_declaration? | (expression (',' expression)*)?) ';' expression? ';' (expression (',' expression)*)? ')' statement // add modifiers
;
// Local declarations and parameters already support modifiers:
local_declaration_statement
: attribute_list* 'await'? 'using'? modifier* variable_declaration ';'
;Reactions are currently unavailable
Metadata
Metadata
Assignees
Type
Projects
Status
Active/Investigating