Repository navigation
Conversation
This is mostly to show how awful this could get. I'm hoping someone has a better suggestion for an approach.
|
I asked GitHub Copilot to review this PR, issue #1662, and the relevant LDM notes. Here is the (unedited) response: Review of dotnet/csharpstandard PR #1825Scope and assessmentI reviewed the PR description, full diff, sole commit, comments, and checks, the complete discussion in issue #1662, and the relevant LDM notes and proposals in the local Bottom line: Keep the PR in draft and substantially revise it. It is useful as an inventory of contexts, but it is not normative text: the central rule is a The successful grammar and example checks do not establish correctness because the change adds no completed executable examples or grammar. Markdownlint fails on the placeholder link at line 631. The renumber and Word-converter jobs completed their substantive processing but ultimately failed while attempting to create check runs ( Decision chronology
FindingsNormative correctness issuesBlocker — The operative rule is undefined and the abstraction is unsound
The “fullest expression” idea has no supporting LDM decision. Scope is determined by the syntactic context containing the declaration, with explicit boundaries. In particular:
The final text should start from the established syntax-context rules, not try to derive them from expression size. High — The definition excludes required pattern contextsLines 631 and 716 say the local is “declared by a pattern … or by an argument list” and then require an expression This is not merely terminology: the 2016-04-06 switch-label rule and C# 8 arm behavior require distinct declaration spaces and scopes. High — Loop rules do not distinguish scope from lifetimeLines 723–726 list loop locations without rules. The 2016-11-30 decision separately establishes narrow scope and fresh per-iteration lifetime for High — Function and embedded-statement boundaries are absentLine 734 is only “Something about anonymous functions.” The C# 7 proposal explicitly covers expression-bodied lambdas and members, while the declaration-space rules require separate anonymous-function and local-function boundaries. The 2016-07-15 decision also requires every unbraced embedded statement to act as a boundary. Without these rules, nested declarations can appear to leak into an outer call, condition, or block. Completeness gapsHigh — Firm C# 7.3 contexts are omittedThe PR has no rules for constructor initializers, field initializers, property initializers, or query-clause expressions. The final 2018-01-03 decisions are unambiguous:
These are part of the shipped language and must not be left to expansion or inference. High — The PR does not complete issue #1662Issue #1662 also calls for synchronization with local-variable and definite-assignment clauses. This PR changes only the scope inventory in Medium — Switch statement and switch expression cases need explicit treatmentThe PR lists only a switch statement's controlling expression at line 722. It omits:
Editorial and link issues
Reliability of issue #1662's AI-generated summaryThe issue discussion is useful research input, but its AI summary should not be cited as authority.
Recommended next steps
Unresolved standards-group questions
|
| - The scope of a local variable declared in a *for_initializer* of a `for` statement ([§13.9.4](statements.md#1394-the-for-statement)) is the *for_initializer*, *for_condition*, *for_iterator*, and *embedded_statement* of the `for` statement. | ||
| - The scope of a local constant declared in a *local_constant_declaration* ([§13.6.3](statements.md#1363-local-constant-declarations)) is the *block* in which the declaration occurs. It is a compile-time error to refer to a local constant in a textual position that precedes its *constant_declarator*. | ||
| - The scope of a variable declared as part of a *foreach_statement*, *using_statement*, *lock_statement* or *query_expression* is determined by the expansion of the given construct. | ||
| - The scope of a local variable declared by a pattern ([§9.1.1](patterns.md#1111-general)) or by an argument list ([§12.6.2.1](expressions.md#12621-general)) is described in [§new](#expression-variables). |
There was a problem hiding this comment.
Also need to include variables declared by switch expressions.
This is mostly to show how awful this could get. I'm hoping someone has a better suggestion for an approach.