Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3164,8 +3164,16 @@ module EstablishTypeDefinitionCores =
if not ctorArgNames.IsEmpty then errorR (Error(FSComp.SR.parsOnlyClassCanTakeValueArguments(), m))

let envinner = AddDeclaredTypars CheckForDuplicateTypars (tycon.Typars m) envinner
let envinner = MakeInnerEnvForTyconRef envinner thisTyconRef false

let envinner = MakeInnerEnvForTyconRef envinner thisTyconRef false

let multiCaseUnionStructCheck (unionCases: UnionCase list) =
if tycon.IsStructRecordOrUnionTycon && unionCases.Length > 1 then
let fieldNames = [ for uc in unionCases do for ft in uc.FieldTable.TrueInstanceFieldsAsList do yield (ft.LogicalName, ft.Range) ]
let distFieldNames = fieldNames |> List.distinctBy fst
if distFieldNames.Length <> fieldNames.Length then
let fieldRanges = distFieldNames |> List.map snd
for m in fieldRanges do
errorR(Error(FSComp.SR.tcStructUnionMultiCaseDistinctFields(), m))

// Notify the Language Service about field names in record/class declaration
let ad = envinner.AccessRights
Expand Down Expand Up @@ -3257,10 +3265,7 @@ module EstablishTypeDefinitionCores =

let hasRQAAttribute = HasFSharpAttribute cenv.g cenv.g.attrib_RequireQualifiedAccessAttribute tycon.Attribs
let unionCases = TcRecdUnionAndEnumDeclarations.TcUnionCaseDecls cenv envinner innerParent thisTy thisTyInst hasRQAAttribute tpenv unionCases
if tycon.IsStructRecordOrUnionTycon && unionCases.Length > 1 then
let fieldNames = [ for uc in unionCases do for ft in uc.FieldTable.TrueInstanceFieldsAsList do yield ft.LogicalName ]
if fieldNames |> List.distinct |> List.length <> fieldNames.Length then
errorR(Error(FSComp.SR.tcStructUnionMultiCaseDistinctFields(), m))
multiCaseUnionStructCheck unionCases

writeFakeUnionCtorsToSink unionCases
let repr = Construct.MakeUnionRepr unionCases
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ tcTupleStructMismatch,"One tuple type is a struct tuple, the other is a referenc
3201,tcModuleAbbrevFirstInMutRec,"In a recursive declaration group, module abbreviations must come after all 'open' declarations and before other declarations"
3202,tcUnsupportedMutRecDecl,"This declaration is not supported in recursive declaration groups"
3203,parsInvalidUseOfRec,"Invalid use of 'rec' keyword"
3204,tcStructUnionMultiCaseDistinctFields,"If a union type has more than one case and is a struct, then all fields within the union type must be given unique names."
3204,tcStructUnionMultiCaseDistinctFields,"If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'."
3206,CallerMemberNameIsOverriden,"The CallerMemberNameAttribute applied to parameter '%s' will have no effect. It is overridden by the CallerFilePathAttribute."
3207,tcFixedNotAllowed,"Invalid use of 'fixed'. 'fixed' may only be used in a declaration of the form 'use x = fixed expr' where the expression is an array, the address of a field, the address of an array element or a string'"
3208,tcCouldNotFindOffsetToStringData,"Could not find method System.Runtime.CompilerServices.OffsetToStringData in references when building 'fixed' expression."
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Pokud je typ sjednocení struktura a obsahuje více než jeden případ, všem polím v tomto typu sjednocení se musí přiřadit jedinečný název.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Pokud je typ sjednocení struktura a obsahuje více než jeden případ, všem polím v tomto typu sjednocení se musí přiřadit jedinečný název.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Wenn ein Union-Typ mehrere case-Anweisungen aufweist und eine Struktur ist, müssen für alle Felder im Union-Typ eindeutige Namen angegeben werden.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Wenn ein Union-Typ mehrere case-Anweisungen aufweist und eine Struktur ist, müssen für alle Felder im Union-Typ eindeutige Namen angegeben werden.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Si un tipo de unión tiene más de un caso y un struct, a todos los campos dentro del tipo de unión se les deben dar nombres únicos.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Si un tipo de unión tiene más de un caso y un struct, a todos los campos dentro del tipo de unión se les deben dar nombres únicos.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Si un type union a plusieurs étiquettes case, et s'il s'agit d'un struct, tous les champs du type union doivent avoir des noms uniques.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Si un type union a plusieurs étiquettes case, et s'il s'agit d'un struct, tous les champs du type union doivent avoir des noms uniques.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Se un tipo di unione contiene più di un case ed è una struttura, è necessario assegnare nomi univoci a tutti i campi all'interno del tipo di unione.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Se un tipo di unione contiene più di un case ed è una struttura, è necessario assegnare nomi univoci a tutti i campi all'interno del tipo di unione.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">共用体型が複数のケースを持つ 1 つの構造体である場合は、共用体型内のすべてのフィールドに一意の名前を付ける必要があります。</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">共用体型が複数のケースを持つ 1 つの構造体である場合は、共用体型内のすべてのフィールドに一意の名前を付ける必要があります。</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">공용 구조체 형식이 둘 이상의 case를 포함하고 구조체인 경우 공용 구조체 형식 내의 모든 필드에 고유한 이름을 지정해야 합니다.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">공용 구조체 형식이 둘 이상의 case를 포함하고 구조체인 경우 공용 구조체 형식 내의 모든 필드에 고유한 이름을 지정해야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Jeśli typ unii ma więcej niż jeden przypadek i jest strukturą, wszystkim polom w typie unii należy nadać unikatowe nazwy.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Jeśli typ unii ma więcej niż jeden przypadek i jest strukturą, wszystkim polom w typie unii należy nadać unikatowe nazwy.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Se um tipo de união tiver mais de um caso e for struct, então todos os campos dentro do tipo de união deverão ter nomes exclusivos.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Se um tipo de união tiver mais de um caso e for struct, então todos os campos dentro do tipo de união deverão ter nomes exclusivos.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Если тип объединения имеет более одного варианта и является структурой, всем полям в типе объединения необходимо присвоить уникальные имена.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Если тип объединения имеет более одного варианта и является структурой, всем полям в типе объединения необходимо присвоить уникальные имена.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">Bir birleşim türü büyük ve küçük harfler içeriyorsa ve bir yapıysa, birleşim türü içindeki tüm alanlara benzersiz adlar verilmelidir.</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">Bir birleşim türü büyük ve küçük harfler içeriyorsa ve bir yapıysa, birleşim türü içindeki tüm alanlara benzersiz adlar verilmelidir.</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">如果联合类型有多个用例且为结构,则必须赋予此联合类型中的所有字段唯一的名称。</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">如果联合类型有多个用例且为结构,则必须赋予此联合类型中的所有字段唯一的名称。</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7513,8 +7513,8 @@
<note />
</trans-unit>
<trans-unit id="tcStructUnionMultiCaseDistinctFields">
<source>If a union type has more than one case and is a struct, then all fields within the union type must be given unique names.</source>
<target state="translated">如果等位型別有一個以上的案例並且為結構,等位型別內所有欄位的名稱就都不得重複。</target>
<source>If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.</source>
<target state="needs-review-translation">如果等位型別有一個以上的案例並且為結構,等位型別內所有欄位的名稱就都不得重複。</target>
<note />
</trans-unit>
<trans-unit id="CallerMemberNameIsOverriden">
Expand Down
Loading