§12.8.4 Simple names doesn't cover finalizers
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
- Área
- documentation
Línea de trabajo
Lee §12.8.4 en standard/expressions.md y luego compara sus contextos de miembros de instancia con §12.8.14 y §12.8.15, a los que enlaza el issue. Añade finalizers a los contextos indicados para que los nombres simples de miembros de instancia se resuelvan como this.I; la tarea estará terminada cuando la redacción coincida con el texto esperado en el issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 818
- Forks
- 99
- Merge medio
- 1 d 16 h
- PR fusionados (30 d)
- 14
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/csharpstandard
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dotnet/csharpstandard#1629 ·
Los mantenedores suelen responder en 1 día
-
type: clarity
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
dotnet/csharpstandard#599 ·
Los mantenedores suelen responder en 1 día
-
9.3.6 Char setAbiertotype: clarity
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
dotnet/csharpstandard#189 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Jon to check Word converter warnings before C# 8 releasePosiblemente ocupada @jskeet la tomó hace 9 días. Abierto
dotnet/csharpstandard#1828 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Nigel to update the grammar checker for C# 8Quizá libre de nuevo @Nigel-Ecma la tomó hace 37 días y no hay ningún pull request abierto. Abierto
dotnet/csharpstandard#1805 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de dotnet/csharpstandard
Issues similares
-
ASP.NET Core container quickstart: `docker-run: debug` task sample is missing its closing braceAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
microsoft/vscode-docs#10499 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
python triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/semantic-kernel#14615 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
vzeol/DeployCraft#125 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/arrow-adbc#4915 · 1 comentario ·
Los mantenedores suelen responder en 1 día