Skip to content

Commit

Permalink
Allow record's parameter_list to be empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyTs committed Sep 17, 2020
1 parent 87f4c9d commit 7befb7f
Show file tree
Hide file tree
Showing 17 changed files with 285 additions and 89 deletions.
3 changes: 0 additions & 3 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -6257,9 +6257,6 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="IDS_FeatureInitOnlySetters" xml:space="preserve">
<value>init-only setters</value>
</data>
<data name="ERR_BadRecordDeclaration" xml:space="preserve">
<value>A positional record must have a non-empty parameter list</value>
</data>
<data name="ERR_InvalidWithReceiverType" xml:space="preserve">
<value>The receiver of a `with` expression must have a non-void type.</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1842,8 +1842,8 @@ internal enum ErrorCode
WRN_SwitchExpressionNotExhaustiveForNullWithWhen = 8847,
WRN_PrecedenceInversion = 8848,
ERR_ExpressionTreeContainsWithExpression = 8849,
ERR_BadRecordDeclaration = 8850,

// Available = 8850,
// Available = 8851,

ERR_AssignmentInitOnly = 8852,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3042,16 +3042,13 @@ private void AddSynthesizedRecordMembersIfNecessary(MembersAndInitializersBuilde
Debug.Assert(builder.RecordDeclarationWithParameters is object);
Debug.Assert(builder.InstanceInitializersForRecordDeclarationWithParameters is object);

// https://github.com/dotnet/roslyn/issues/44677
// The semantics of an empty parameter list have not been decided. Error for now
if (paramList.ParameterCount == 0)
var ctor = addCtor(builder.RecordDeclarationWithParameters);

if (ctor.ParameterCount != 0)
{
diagnostics.Add(ErrorCode.ERR_BadRecordDeclaration, paramList.Location);
var existingOrAddedMembers = addProperties(ctor.Parameters);
addDeconstruct(ctor, existingOrAddedMembers);
}

var ctor = addCtor(builder.RecordDeclarationWithParameters);
var existingOrAddedMembers = addProperties(ctor.Parameters);
addDeconstruct(ctor, existingOrAddedMembers);
}

addCopyCtor();
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Poziční záznam musí mít modifikátor data a neprázdný seznam parametrů.</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Ein positioneller Datensatz muss sowohl einen data-Modifizierer als auch eine nicht leere Parameterliste aufweisen.</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Un registro posicional debe tener un modificador "data" y una lista de parámetros no vacía</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Un enregistrement positionnel doit avoir à la fois un modificateur 'data' et une liste de paramètres non vide</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Un record posizionale deve include sia un modificatore 'data' che un elenco di parametri non vuoto</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">位置指定レコードには、'data' 修飾子と空でないパラメーター リストの両方が必要です</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">위치 레코드에는 'data' 한정자와 비어 있지 않은 매개 변수 목록이 둘 다 있어야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Rekord pozycyjny musi mieć zarówno modyfikator „data”, jak i niepustą listę parametrów</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Um registro posicional precisa ter um modificador 'data' e uma lista de parâmetros não vazios</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Позиционная запись должна иметь модификатор "data" и непустой список параметров.</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">Konumsal bir kaydın hem 'data' değiştiricisi hem de boş olmayan bir parametre listesi olmalıdır</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">位置记录必须同时具有 "data" 修饰符和非空参数列表</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<target state="new">Records may only inherit from object or another record</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordDeclaration">
<source>A positional record must have a non-empty parameter list</source>
<target state="needs-review-translation">位置記錄必須同時具有 'data' 修飾元及非空白的參數清單</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadRecordMemberForPositionalParameter">
<source>Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</source>
<target state="new">Record member '{0}' must be a readable instance property of type '{1}' to match positional parameter '{2}'.</target>
Expand Down
Loading

0 comments on commit 7befb7f

Please sign in to comment.