§12.8.4 Simple names doesn't cover finalizers
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 76/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp
調査の方向性
standard/expressions.md の §12.8.4 を読み、インスタンスメンバーのコンテキストを、issue がリンクしている §12.8.14 および §12.8.15 と比較してください。単純なインスタンスメンバー名が this.I として解決されるよう、列挙されたコンテキストに finalizer を追加してください。issue の期待されるテキストと文言が一致したら完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
In draft-v8, §12.8.4 Simple names turns a simple name that refers to an instance member into this.I only in these cases:
Otherwise, if
Tis the instance type of the immediately enclosing class or struct type, if the lookup identifies an instance member, and if the reference occurs within the block of an instance constructor, an instance method, or an instance accessor (§12.2.1), the result is the same as a member access (§12.8.7) of the formthis.I.
Finalizers aren't in that list. In a finalizer, a simple name for an instance member falls through to the next bullet:
Otherwise, the result is the same as a member access (§12.8.7) of the form
T.IorT.I<A₁, ..., Aₑ>.
When T is a type, §12.8.7 Member access handles only static members and nested types, then says "Otherwise, E.I is an invalid member reference, and a compile-time error occurs." So by the standard's wording, x = 0; in a finalizer is an error, even though compilers accept it.
§12.8.14 This access and §12.8.15 Base access both list finalizers explicitly, so the omission looks unintentional.
Finalizers have been in the language since C# 1, so this is in scope for the C# 8 standard.
Example
This compiles today:
class C
{
private int x;
~C()
{
x = 0; // simple name for an instance field in a finalizer
M(); // simple name for an instance method in a finalizer
}
void M() { }
}
Expected behavior
§12.8.4 should list finalizers alongside the other contexts, as §12.8.14 and §12.8.15 do:
Otherwise, if
Tis the instance type of the immediately enclosing class or struct type, if the lookup identifies an instance member, and if the reference occurs within the block of an instance constructor, an instance method, an instance accessor (§12.2.1), or a finalizer, the result is the same as a member access (§12.8.7) of the formthis.I.
Additional context
§15.13 Finalizers says a finalizer's body "corresponds exactly to the method_body of an instance method." If that were meant to make a finalizer's body count as an instance method's block here, §12.8.14 and §12.8.15 wouldn't need to list finalizers. #577 asks what "corresponds exactly to" means.
The same sentence says block, which doesn't cover expression bodies. That's the same problem #1434 describes for "block body," so I've left it out of this issue.
- 主要言語
- C#
- スター
- 818
- フォーク
- 99
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/csharpstandard のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dotnet/csharpstandard#1629 ·
メンテナーはふだん 1 日以内に返信
-
type: clarity
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
dotnet/csharpstandard#599 ·
メンテナーはふだん 1 日以内に返信
-
9.3.6 Char setオープンtype: clarity
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
dotnet/csharpstandard#189 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
Jon to check Word converter warnings before C# 8 release対応中かも @jskeet が 9 日前に担当しました。 オープン
dotnet/csharpstandard#1828 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Nigel to update the grammar checker for C# 8再び着手できるかも @Nigel-Ecma が 37 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
dotnet/csharpstandard#1805 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
dotnet/csharpstandard の issue をすべて見る
似ている issue
-
ASP.NET Core container quickstart: `docker-run: debug` task sample is missing its closing braceオープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoft/vscode-docs#10499 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
python triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/semantic-kernel#14615 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
vzeol/DeployCraft#125 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/arrow-adbc#4915 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信