§12.8.4 Simple names doesn't cover finalizers
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 76/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- csharp
- Ambito
- documentation
Direzione di ricerca
Leggi §12.8.4 in standard/expressions.md, poi confronta i relativi contesti dei membri di istanza con §12.8.14 e §12.8.15, a cui rimanda l’issue. Aggiungi finalizers ai contesti elencati affinché i nomi semplici dei membri di istanza vengano risolti come this.I; il lavoro è completato quando la formulazione corrisponde al testo previsto nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C#
- Stelle
- 818
- Fork
- 99
- Merge medio
- 1g 16h
- PR unite (30g)
- 14
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dotnet/csharpstandard
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dotnet/csharpstandard#1629 ·
I maintainer di solito rispondono entro 1 giorno
-
type: clarity
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
dotnet/csharpstandard#599 ·
I maintainer di solito rispondono entro 1 giorno
-
9.3.6 Char setApertatype: clarity
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
dotnet/csharpstandard#189 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Jon to check Word converter warnings before C# 8 releaseForse già presa @jskeet l’ha presa 7 giorni fa. Aperta
dotnet/csharpstandard#1828 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Nigel to update the grammar checker for C# 8Forse di nuovo libera @Nigel-Ecma l’ha presa 35 giorni fa e non c’è nessuna pull request aperta. Aperta
dotnet/csharpstandard#1805 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di dotnet/csharpstandard
Issue simili
-
area-signalr
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
dotnet/aspnetcore#69842 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 2 giorni
-
bug needs-triage
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 78/100
microsoft/microsoft-ui-reactor#1373 ·
I maintainer di solito rispondono entro 1 giorno
-
Client customer-reported KeyVault needs-team-attention question Service Attention
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Azure/azure-sdk-for-net#63861 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
:watch: Not Triaged dotnet-csharp/svc fundamentals/subsvc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno