From 8796cdced83631e51b4fb73549eb030463753dc0 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez <edgar.gonzalez@fundourselves.com> Date: Tue, 1 Aug 2023 19:09:43 +0200 Subject: [PATCH 1/5] Better error message when using wrong anon record --- src/Compiler/Checking/ConstraintSolver.fs | 7 +++++- src/Compiler/FSComp.txt | 3 ++- src/Compiler/xlf/FSComp.txt.cs.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.de.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.es.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.fr.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.it.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.ja.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.ko.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.pl.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.ru.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.tr.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 21 +++++++++++------- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 21 +++++++++++------- .../Types/RecordTypes/AnonymousRecords.fs | 22 +++++++++++++++++++ tests/fsharp/typecheck/sigs/neg113.bsl | 2 +- tests/fsharp/typecheck/sigs/neg113.vsbsl | 2 +- tests/fsharp/typecheck/sigs/neg_anon_1.bsl | 2 +- 19 files changed, 202 insertions(+), 109 deletions(-) diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index f74e7509df9..521bb2751d6 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -1099,7 +1099,12 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon | Overlap (missingFields, extraFields) -> FSComp.SR.tcAnonRecdFieldNameMismatch(string missingFields, string extraFields) | CompletelyDifferent missingFields -> - FSComp.SR.tcAnonRecdFieldNameDifferent(string missingFields) + match missingFields with + | [missingField] -> + FSComp.SR.tcAnonRecdSingleFieldNameDifferent(missingField) + | _ -> + let missingFields = String.concat ", " missingFields + FSComp.SR.tcAnonRecdMultipleFieldNameDifferent(missingFields) ErrorD (ConstraintSolverError(message, csenv.m,m2)) else diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index b6d363e374e..885d3ce3f36 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1399,7 +1399,8 @@ tcAnonRecdSingleFieldNameSubset,"This anonymous record is missing field '%s'." tcAnonRecdMultipleFieldsNameSubset,"This anonymous record is missing fields '%s'." tcAnonRecdSingleFieldNameSuperset,"This anonymous record has an extra field. Remove field '%s'." tcAnonRecdMultipleFieldsNameSuperset,"This anonymous record has extra fields. Remove fields '%s'." -tcAnonRecdFieldNameDifferent,"This is the wrong anonymous record. It should have the fields %s." +tcAnonRecdSingleFieldNameDifferent,"This anonymous record should have field '%s'." +tcAnonRecdMultipleFieldNameDifferent,"This anonymous record should have fields '%s'." keywordDescriptionAbstract,"Indicates a method that either has no implementation in the type in which it is declared or that is virtual and has a default implementation." keywordDescriptionAnd,"Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters." keywordDescriptionAs,"Used to give the current class object an object name. Also used to give a name to a whole pattern within a pattern match." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 122ea1de3b8..05dec13f654 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1022,9 +1022,9 @@ <target state="translated">Pole {0} se v tomto výrazu záznamu vyskytuje vícekrát.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Toto je nesprávný anonymní záznam. Měl by mít pole {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Neplatná deklarace typu anonymního záznamu</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Dva typy anonymních záznamů jsou z různých sestavení: {0} a {1}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Tento anonymní záznam neodpovídá přesně očekávanému tvaru. Přidejte chybějící pole {0} a odeberte nadbytečná pole {1}.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">Nejde volat metodu rozšíření byref {0}. První parametr vyžaduje, aby hodnota byla měnitelná nebo typu byref, která není jen pro čtení.</target> diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 230776c2d0e..781040ce0fe 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1022,9 +1022,9 @@ <target state="translated">Das Feld "{0}" ist in diesem Datensatzausdruck mehrmals vorhanden.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Dies ist der falsche anonyme Datensatz. Er muss folgende Felder umfassen: {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Ungültige Deklaration für anonymen Datensatztyp.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Zwei anonyme Datensatztypen stammen aus verschiedenen Assemblys: "{0}" und "{1}".</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Dieser anonyme Datensatz stimmt nicht genau mit der erwarteten Form überein. Fügen Sie die fehlenden Felder ({0}) hinzu, und entfernen Sie die zusätzlichen Felder ({1}).</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">Die ByRef-Erweiterungsmethode "{0}" kann nicht aufgerufen werden. Für den ersten Parameter muss der Wert änderbar sein oder einem nicht schreibgeschützten ByRef-Typ entsprechen.</target> diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 735892b2d63..10dbe1957d8 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1022,9 +1022,9 @@ <target state="translated">El campo "{0}" aparece varias veces en esta expresión de registro.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Este es un registro anónimo incorrecto. Debe tener los campos {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Declaración de tipo de registro anónimo no válido.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Dos tipos de registro anónimos provienen de diferentes ensamblados "{0}" y "{1}"</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Este registro anónimo no coincide exactamente con la forma esperada. Agregue los campos que faltan {0} y quite los campos adicionales {1}.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">No se puede llamar al método de extensión de byref "{0}". El primer parámetro requiere que el valor sea mutable o un tipo de byref que no sea de solo lectura.</target> diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index f0b0110c1d4..19672f05f99 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1022,9 +1022,9 @@ <target state="translated">Le champ «{0}» apparaît plusieurs fois dans cette expression d’enregistrement.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Il s'agit de l'enregistrement anonyme incorrect. Il doit contenir les champs {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Déclaration de type d'enregistrement anonyme non valide.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Deux types d'enregistrement anonyme proviennent d'assemblys différents '{0}' et '{1}'</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Cet enregistrement anonyme ne correspond pas exactement à la forme attendue. Ajoutez les champs manquants {0} et supprimez les champs supplémentaires {1}.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">Impossible d’appeler la méthode d’extension byref « {0} ». Le premier paramètre nécessite que la valeur soit mutable ou un type byref autre qu'en lecture seule.</target> diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 30c0a6222a1..bf687dae6d6 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1022,9 +1022,9 @@ <target state="translated">Il campo '{0}' viene visualizzato più volte in questa espressione di record.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Si tratta del record anonimo errato. Deve includere i campi {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">La dichiarazione di tipo Record anonimo non è valida.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Due tipi di record anonimo provengono da assembly diversi, '{0}' e '{1}'</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Questo record anonimo non corrisponde esattamente alla forma prevista. Aggiungere i campi mancanti {0} e rimuovere i campi aggiuntivi {1}.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">Non è possibile chiamare il metodo di estensione byref '{0}. Il valore del primo parametro deve essere modificabile oppure un tipo byref non di sola lettura.</target> diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 3e8d4113a7b..9c8c6f84a21 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1022,9 +1022,9 @@ <target state="translated">このレコード式に、フィールド '{0}' が複数回出現します。</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">この匿名レコードは正しくありません。フィールド {0} を含んでいる必要があります。</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">匿名レコードの型宣言が無効です。</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">2 つの匿名レコードの種類は、'{0}' と '{1}' の異なるアセンブリからのものです</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">この匿名レコードは、予期された形状と完全には一致していません。不足しているフィールド {0} を追加し、不要なフィールド {1} を削除してください。</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">byref 拡張メソッド '{0} を呼び出すことはできません。最初のパラメーターでは、値を変更可能な byref 型または読み取り専用以外の byref 型にする必要があります。</target> diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index f15468f49eb..07ddc308cf7 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1022,9 +1022,9 @@ <target state="translated">'{0}' 필드가 이 레코드 식에 여러 번 나타납니다.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">잘못된 익명 레코드입니다. {0} 필드가 있어야 합니다.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">익명 레코드 형식 선언이 잘못되었습니다.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">두 무명 레코드 형식은 서로 다른 어셈블리 '{0}' 및 '{1}'에서 가져왔습니다.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">이 익명 레코드는 필요한 도형과 정확하게 일치하지 않습니다. 누락된 필드 {0}을(를) 추가하고 추가 필드 {1}을(를) 제거하세요.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">byref 확장 메서드 '{0}'을(를) 호출할 수 없습니다. 첫 번째 매개 변수는 변경할 수 있거나 읽기 전용이 아닌 byref 형식인 값이 필요합니다.</target> diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 3f1b221b367..ded83d12192 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1022,9 +1022,9 @@ <target state="translated">Pole „{0}” występuje wielokrotnie w tym wyrażeniu rekordu.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">To jest nieprawidłowy rekord anonimowy. Powinien zawierać pola {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Nieprawidłowa deklaracja typu rekordu anonimowego.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Dwa typy rekordów anonimowych pochodzą z różnych zestawów: „{0}” i „{1}”</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Ten rekord anonimowy nie jest dokładnie zgodny z oczekiwanym kształtem. Dodaj brakujące pola {0} i usuń dodatkowe pola {1}.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">Nie można wywołać metody rozszerzenia byref „{0}”. Pierwszy parametr wymaga, aby wartość była typem byref zmiennym lub innym niż tylko do odczytu.</target> diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index f48acd7ac59..6900a8c1b1c 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1022,9 +1022,9 @@ <target state="translated">O campo '{0}' aparece várias vezes nesta expressão de registro.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Este é o registro anônimo errado. Ele deve ter os campos {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Declaração inválida de tipo de Registro Anônimo.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Dois tipos de registro anônimos são de diferentes assemblies '{0}' e '{1}'</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Este registro anônimo não corresponde exatamente à forma esperada. Adicione os campos ausentes {0} e remova os campos extras {1}.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">Não é possível chamar o método de extensão de byref '{0}. O primeiro parâmetro requer que o valor seja mutável ou não seja byref somente leitura.</target> diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 3fc0f495b55..4e99a54a289 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1022,9 +1022,9 @@ <target state="translated">Поле "{0}" появляется несколько раз в данном выражении записи.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Неправильная анонимная запись. Она должна содержать поля {0}.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Недопустимое объявление типа анонимной записи.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">Два типа анонимных записей принадлежат различным сборкам '{0}' и '{1}'</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Эта анонимная запись не соответствует ожидаемой форме. Добавьте недостающие поля {0} и удалите лишние поля {1}.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">Не удается вызвать метод расширения byref "{0}". В качестве первого параметра необходимо указать изменяемое значение или значение типа byref, доступное не только для чтения.</target> diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 99c064c052a..1d44855de1c 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1022,9 +1022,9 @@ <target state="translated">'{0}' alanı bu kayıt ifadesinde birden fazla yerde görünüyor.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">Bu anonim kayıt yanlış. Kayıt, {0} alanlarını içermelidir.</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">Anonim Kayıt türü bildirimi geçersiz.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">İki anonim kayıt türü, birbirinden farklı olan '{0}' ve '{1}' derlemelerinden</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">Bu anonim kayıt, beklenen şekille tam olarak eşleşmiyor. Eksik {0} alanlarını ekleyin ve ek {1} alanlarını kaldırın.</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">'{0}' byref genişletme metodu çağrılamıyor. İlk parametre, değerin değişebilir olmasını veya salt okunur olmayan bir byref türünde olmasını gerektiriyor.</target> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index a4ddd603216..9b85bbc02d2 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1022,9 +1022,9 @@ <target state="translated">字段“{0}”在此记录表达式中多次出现。</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">此匿名记录不正确。它应具有字段 {0}。</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">匿名记录类型声明无效。</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">两个匿名记录类型来自不同的程序集“{0}”和“{1}”</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">此匿名记录与预期的形状不完全匹配。请添加缺少的字段 {0} 并删除额外的字段 {1}。</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">无法调用 byref 扩展方法 "{0}"。第一个参数要求该值是可变的或非只读的 byref 类型。</target> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 5044ef52e5b..989bd385eda 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1022,9 +1022,9 @@ <target state="translated">欄位 '{0}' 在這個記錄運算式中出現多次。</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameDifferent"> - <source>This is the wrong anonymous record. It should have the fields {0}.</source> - <target state="translated">此為錯誤的匿名記錄。其應有欄位 {0}。</target> + <trans-unit id="tcAnonRecdFieldNameMismatch"> + <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> + <target state="new">This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdInvalid"> @@ -1032,6 +1032,11 @@ <target state="translated">匿名記錄型別宣告無效。</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> + <source>This anonymous record should have fields '{0}'.</source> + <target state="new">This anonymous record should have fields '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> <source>This anonymous record is missing fields '{0}'.</source> <target state="new">This anonymous record is missing fields '{0}'.</target> @@ -1042,6 +1047,11 @@ <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> <note /> </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> + <source>This anonymous record should have field '{0}'.</source> + <target state="new">This anonymous record should have field '{0}'.</target> + <note /> + </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> <source>This anonymous record is missing field '{0}'.</source> <target state="new">This anonymous record is missing field '{0}'.</target> @@ -8387,11 +8397,6 @@ <target state="translated">有兩個匿名的記錄類型來自不同的組件 '{0}' 和 '{1}'</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdFieldNameMismatch"> - <source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source> - <target state="translated">此匿名記錄與預期的圖形未完全相符。請新增缺少的欄位 {0},並移除額外的欄位 {1}。</target> - <note /> - </trans-unit> <trans-unit id="tcCannotCallExtensionMethodInrefToByref"> <source>Cannot call the byref extension method '{0}. The first parameter requires the value to be mutable or a non-readonly byref type.</source> <target state="translated">無法呼叫 byref 擴充方法 '{0}。第一個參數需要值可變動,或為非唯讀 byref 類型。</target> diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs index faa24a3e17a..f6d4af74225 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs @@ -63,6 +63,28 @@ let x () : {| A: int |} = {| A = 123 ; B = ""; C = 1 |} |> withDiagnostics [ (Error 1, Line 2, Col 29, Line 2, Col 58, "This anonymous record has extra fields. Remove fields 'B, C'.") ] + + [<Fact>] + let ``Using the wrong anon record with single field`` () = + Fsx """ +let x() = ({| b = 2 |} = {| a = 2 |} ) +""" + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 2, Col 26, Line 2, Col 37, "This anonymous record should have field 'b'.") + ] + + [<Fact>] + let ``Using the wrong anon record with multiple fields`` () = + Fsx """ +let x() = ({| b = 2; c = 3 |} = {| a = 2 |} ) +""" + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 2, Col 33, Line 2, Col 44, "This anonymous record should have fields 'b, c'.") + ] [<Fact>] let ``Anonymous Records with duplicate labels - Copy and update expression`` () = diff --git a/tests/fsharp/typecheck/sigs/neg113.bsl b/tests/fsharp/typecheck/sigs/neg113.bsl index c61b8907b47..7d371890705 100644 --- a/tests/fsharp/typecheck/sigs/neg113.bsl +++ b/tests/fsharp/typecheck/sigs/neg113.bsl @@ -1,7 +1,7 @@ neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg113.fs(7,41,7,52): typecheck error FS0001: This is the wrong anonymous record. It should have the fields [b]. +neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b'. neg113.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion diff --git a/tests/fsharp/typecheck/sigs/neg113.vsbsl b/tests/fsharp/typecheck/sigs/neg113.vsbsl index c61b8907b47..7d371890705 100644 --- a/tests/fsharp/typecheck/sigs/neg113.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg113.vsbsl @@ -1,7 +1,7 @@ neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg113.fs(7,41,7,52): typecheck error FS0001: This is the wrong anonymous record. It should have the fields [b]. +neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b'. neg113.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion diff --git a/tests/fsharp/typecheck/sigs/neg_anon_1.bsl b/tests/fsharp/typecheck/sigs/neg_anon_1.bsl index 5f4522e7c1d..87f1b70e103 100644 --- a/tests/fsharp/typecheck/sigs/neg_anon_1.bsl +++ b/tests/fsharp/typecheck/sigs/neg_anon_1.bsl @@ -1,7 +1,7 @@ neg_anon_1.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg_anon_1.fs(7,41,7,52): typecheck error FS0001: This is the wrong anonymous record. It should have the fields [b]. +neg_anon_1.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b'. neg_anon_1.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion From 01b37edaf84551a046541828acd6c5df7d6867b5 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez <edgar.gonzalez@fundourselves.com> Date: Tue, 1 Aug 2023 21:02:17 +0200 Subject: [PATCH 2/5] PR Feedback --- src/Compiler/Checking/ConstraintSolver.fs | 3 +++ src/Compiler/FSComp.txt | 6 +++--- src/Compiler/xlf/FSComp.txt.cs.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.de.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.es.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.fr.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.it.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.ja.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.ko.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.pl.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.ru.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.tr.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 12 ++++++------ .../Types/RecordTypes/AnonymousRecords.fs | 6 +++--- 16 files changed, 87 insertions(+), 84 deletions(-) diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index 521bb2751d6..37066021b09 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -1087,6 +1087,7 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon | [missingField] -> FSComp.SR.tcAnonRecdSingleFieldNameSubset(string missingField) | _ -> + let missingFields = missingFields |> List.map(sprintf "'%s'") let missingFields = String.concat ", " missingFields FSComp.SR.tcAnonRecdMultipleFieldsNameSubset(string missingFields) | Superset extraFields -> @@ -1094,6 +1095,7 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon | [extraField] -> FSComp.SR.tcAnonRecdSingleFieldNameSuperset(string extraField) | _ -> + let extraFields = extraFields |> List.map(sprintf "'%s'") let extraFields = String.concat ", " extraFields FSComp.SR.tcAnonRecdMultipleFieldsNameSuperset(string extraFields) | Overlap (missingFields, extraFields) -> @@ -1103,6 +1105,7 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon | [missingField] -> FSComp.SR.tcAnonRecdSingleFieldNameDifferent(missingField) | _ -> + let missingFields = missingFields |> List.map(sprintf "'%s'") let missingFields = String.concat ", " missingFields FSComp.SR.tcAnonRecdMultipleFieldNameDifferent(missingFields) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 885d3ce3f36..f65b20ccefd 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1396,11 +1396,11 @@ tcAnonRecdInvalid,"Invalid Anonymous Record type declaration." tcAnonRecdCcuMismatch,"Two anonymous record types are from different assemblies '%s' and '%s'" tcAnonRecdFieldNameMismatch,"This anonymous record does not exactly match the expected shape. Add the missing fields %s and remove the extra fields %s." tcAnonRecdSingleFieldNameSubset,"This anonymous record is missing field '%s'." -tcAnonRecdMultipleFieldsNameSubset,"This anonymous record is missing fields '%s'." +tcAnonRecdMultipleFieldsNameSubset,"This anonymous record is missing fields %s." tcAnonRecdSingleFieldNameSuperset,"This anonymous record has an extra field. Remove field '%s'." -tcAnonRecdMultipleFieldsNameSuperset,"This anonymous record has extra fields. Remove fields '%s'." +tcAnonRecdMultipleFieldsNameSuperset,"This anonymous record has extra fields. Remove fields %s." tcAnonRecdSingleFieldNameDifferent,"This anonymous record should have field '%s'." -tcAnonRecdMultipleFieldNameDifferent,"This anonymous record should have fields '%s'." +tcAnonRecdMultipleFieldNameDifferent,"This anonymous record should have fields %s." keywordDescriptionAbstract,"Indicates a method that either has no implementation in the type in which it is declared or that is virtual and has a default implementation." keywordDescriptionAnd,"Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters." keywordDescriptionAs,"Used to give the current class object an object name. Also used to give a name to a whole pattern within a pattern match." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 05dec13f654..8abccbdfc89 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 781040ce0fe..daa4513d0fa 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 10dbe1957d8..f343fcc00a6 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 19672f05f99..5e72fce363f 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index bf687dae6d6..f9650b5f76b 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 9c8c6f84a21..a5b82821077 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 07ddc308cf7..d40d3c19a72 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index ded83d12192..2d7eb833344 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 6900a8c1b1c..1a628ad6c26 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 4e99a54a289..cc6d6b9d519 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 1d44855de1c..8964a021403 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 9b85bbc02d2..dd6ecb89ad6 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 989bd385eda..64b81ba9385 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1033,18 +1033,18 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields '{0}'.</source> - <target state="new">This anonymous record should have fields '{0}'.</target> + <source>This anonymous record should have fields {0}.</source> + <target state="new">This anonymous record should have fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> - <source>This anonymous record is missing fields '{0}'.</source> - <target state="new">This anonymous record is missing fields '{0}'.</target> + <source>This anonymous record is missing fields {0}.</source> + <target state="new">This anonymous record is missing fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSuperset"> - <source>This anonymous record has extra fields. Remove fields '{0}'.</source> - <target state="new">This anonymous record has extra fields. Remove fields '{0}'.</target> + <source>This anonymous record has extra fields. Remove fields {0}.</source> + <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs index f6d4af74225..fa2df582b74 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs @@ -39,7 +39,7 @@ let x () : {| A: int; B: string; C: int |} = {| A = 123 |} |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 48, Line 2, Col 61, "This anonymous record is missing fields 'B, C'.") + (Error 1, Line 2, Col 48, Line 2, Col 61, "This anonymous record is missing fields 'B', 'C'.") ] [<Fact>] @@ -61,7 +61,7 @@ let x () : {| A: int |} = {| A = 123 ; B = ""; C = 1 |} |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 29, Line 2, Col 58, "This anonymous record has extra fields. Remove fields 'B, C'.") + (Error 1, Line 2, Col 29, Line 2, Col 58, "This anonymous record has extra fields. Remove fields 'B', 'C'.") ] [<Fact>] @@ -83,7 +83,7 @@ let x() = ({| b = 2; c = 3 |} = {| a = 2 |} ) |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 33, Line 2, Col 44, "This anonymous record should have fields 'b, c'.") + (Error 1, Line 2, Col 33, Line 2, Col 44, "This anonymous record should have fields 'b', 'c'.") ] [<Fact>] From ef528e1535aa49596096df8a4fdbd71287e0f338 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez <edgar.gonzalez@fundourselves.com> Date: Wed, 2 Aug 2023 10:14:54 +0200 Subject: [PATCH 3/5] Improve error message as suggested --- src/Compiler/Checking/ConstraintSolver.fs | 15 ++++++++---- src/Compiler/FSComp.txt | 4 ++-- src/Compiler/xlf/FSComp.txt.cs.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.de.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.es.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.fr.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.it.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.ja.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.ko.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.pl.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.ru.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.tr.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 8 +++---- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 8 +++---- .../Types/RecordTypes/AnonymousRecords.fs | 23 +++++++++++++++++-- 16 files changed, 85 insertions(+), 61 deletions(-) diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index 37066021b09..0bd5707ebe5 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -1078,7 +1078,9 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon elif Set.intersect first second <> Set.empty then Overlap(firstOnly, secondOnly) else - CompletelyDifferent(Seq.toList first) + let first = Set.toList first + let second = Set.toList second + CompletelyDifferent(first, second) let message = match anonInfo1.SortedNames, anonInfo2.SortedNames with @@ -1101,13 +1103,16 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon | Overlap (missingFields, extraFields) -> FSComp.SR.tcAnonRecdFieldNameMismatch(string missingFields, string extraFields) | CompletelyDifferent missingFields -> - match missingFields with - | [missingField] -> - FSComp.SR.tcAnonRecdSingleFieldNameDifferent(missingField) + let missingFields, usedFields = missingFields + match missingFields, usedFields with + | [ missingField ], [ usedField ] -> + FSComp.SR.tcAnonRecdSingleFieldNameDifferent(missingField, usedField) | _ -> let missingFields = missingFields |> List.map(sprintf "'%s'") let missingFields = String.concat ", " missingFields - FSComp.SR.tcAnonRecdMultipleFieldNameDifferent(missingFields) + let usedFields = usedFields |> List.map(sprintf "'%s'") + let usedFields = String.concat ", " usedFields + FSComp.SR.tcAnonRecdMultipleFieldNameDifferent(missingFields, usedFields) ErrorD (ConstraintSolverError(message, csenv.m,m2)) else diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index f65b20ccefd..2aa049d2c79 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1399,8 +1399,8 @@ tcAnonRecdSingleFieldNameSubset,"This anonymous record is missing field '%s'." tcAnonRecdMultipleFieldsNameSubset,"This anonymous record is missing fields %s." tcAnonRecdSingleFieldNameSuperset,"This anonymous record has an extra field. Remove field '%s'." tcAnonRecdMultipleFieldsNameSuperset,"This anonymous record has extra fields. Remove fields %s." -tcAnonRecdSingleFieldNameDifferent,"This anonymous record should have field '%s'." -tcAnonRecdMultipleFieldNameDifferent,"This anonymous record should have fields %s." +tcAnonRecdSingleFieldNameDifferent,"This anonymous record should have field '%s', not '%s'." +tcAnonRecdMultipleFieldNameDifferent,"This anonymous record should have fields %s, not %s." keywordDescriptionAbstract,"Indicates a method that either has no implementation in the type in which it is declared or that is virtual and has a default implementation." keywordDescriptionAnd,"Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters." keywordDescriptionAs,"Used to give the current class object an object name. Also used to give a name to a whole pattern within a pattern match." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 8abccbdfc89..bbbc9d9c6ac 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index daa4513d0fa..e9f57851e96 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f343fcc00a6..fd35db753ff 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 5e72fce363f..9ee01c2ba9c 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index f9650b5f76b..01225fd787c 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index a5b82821077..c8f54bad7da 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index d40d3c19a72..659af604161 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 2d7eb833344..b96ef38f558 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 1a628ad6c26..ffce82a479b 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index cc6d6b9d519..beb51c72706 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 8964a021403..4e3e7fa3d34 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index dd6ecb89ad6..ae66286695e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 64b81ba9385..50acbd5369d 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1033,8 +1033,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}.</source> - <target state="new">This anonymous record should have fields {0}.</target> + <source>This anonymous record should have fields {0}, not {1}.</source> + <target state="new">This anonymous record should have fields {0}, not {1}.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1048,8 +1048,8 @@ <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}'.</source> - <target state="new">This anonymous record should have field '{0}'.</target> + <source>This anonymous record should have field '{0}', not '{1}'.</source> + <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs index fa2df582b74..7e2d6a99e40 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs @@ -72,7 +72,7 @@ let x() = ({| b = 2 |} = {| a = 2 |} ) |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 26, Line 2, Col 37, "This anonymous record should have field 'b'.") + (Error 1, Line 2, Col 26, Line 2, Col 37, "This anonymous record should have field 'b', not 'a'.") ] [<Fact>] @@ -83,8 +83,27 @@ let x() = ({| b = 2; c = 3 |} = {| a = 2 |} ) |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 33, Line 2, Col 44, "This anonymous record should have fields 'b', 'c'.") + (Error 1, Line 2, Col 33, Line 2, Col 44, "This anonymous record should have fields 'b', 'c', not 'a'.") ] + + [<Fact>] + let ``Using the wrong anon record with multiple fields 2`` () = + Fsx """ +let x() = ({| b = 2; c = 3 |} = {| a = 2; d = "" |} ) +""" + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 2, Col 33, Line 2, Col 52, "This anonymous record should have fields 'b', 'c', not 'a', 'd'.") + ] + + [<Fact>] + let ``Two anon records with no fields`` () = + Fsx """ +let x() = ({||} = {||}) +""" + |> compile + |> shouldSucceed [<Fact>] let ``Anonymous Records with duplicate labels - Copy and update expression`` () = From e697aa52ecac5783eefd29ce626378156d6d1377 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez <edgar.gonzalez@fundourselves.com> Date: Wed, 2 Aug 2023 10:19:04 +0200 Subject: [PATCH 4/5] update baselines --- tests/fsharp/typecheck/sigs/neg113.bsl | 2 +- tests/fsharp/typecheck/sigs/neg113.vsbsl | 2 +- tests/fsharp/typecheck/sigs/neg_anon_1.bsl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/fsharp/typecheck/sigs/neg113.bsl b/tests/fsharp/typecheck/sigs/neg113.bsl index 7d371890705..dd3cb324374 100644 --- a/tests/fsharp/typecheck/sigs/neg113.bsl +++ b/tests/fsharp/typecheck/sigs/neg113.bsl @@ -1,7 +1,7 @@ neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b'. +neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b', not 'a'. neg113.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion diff --git a/tests/fsharp/typecheck/sigs/neg113.vsbsl b/tests/fsharp/typecheck/sigs/neg113.vsbsl index 7d371890705..dd3cb324374 100644 --- a/tests/fsharp/typecheck/sigs/neg113.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg113.vsbsl @@ -1,7 +1,7 @@ neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b'. +neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b', not 'a'. neg113.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion diff --git a/tests/fsharp/typecheck/sigs/neg_anon_1.bsl b/tests/fsharp/typecheck/sigs/neg_anon_1.bsl index 87f1b70e103..c0df80fa44c 100644 --- a/tests/fsharp/typecheck/sigs/neg_anon_1.bsl +++ b/tests/fsharp/typecheck/sigs/neg_anon_1.bsl @@ -1,7 +1,7 @@ neg_anon_1.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg_anon_1.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b'. +neg_anon_1.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b', not 'a'. neg_anon_1.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion From 7a70b0582929de6d059f008627872021fdf102e0 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez <edgar.gonzalez@fundourselves.com> Date: Wed, 2 Aug 2023 17:44:14 +0200 Subject: [PATCH 5/5] one more time --- src/Compiler/Checking/ConstraintSolver.fs | 15 ++++++++++--- src/Compiler/FSComp.txt | 6 +++-- src/Compiler/xlf/FSComp.txt.cs.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.de.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.es.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.fr.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.it.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.ja.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.ko.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.pl.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.ru.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.tr.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 22 ++++++++++++++----- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 22 ++++++++++++++----- .../Types/RecordTypes/AnonymousRecords.fs | 17 +++++++++++--- tests/fsharp/typecheck/sigs/neg113.bsl | 2 +- tests/fsharp/typecheck/sigs/neg113.vsbsl | 2 +- tests/fsharp/typecheck/sigs/neg_anon_1.bsl | 2 +- 19 files changed, 241 insertions(+), 89 deletions(-) diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index 0bd5707ebe5..fa20b108362 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -1106,13 +1106,22 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon let missingFields, usedFields = missingFields match missingFields, usedFields with | [ missingField ], [ usedField ] -> - FSComp.SR.tcAnonRecdSingleFieldNameDifferent(missingField, usedField) - | _ -> + FSComp.SR.tcAnonRecdSingleFieldNameSingleDifferent(missingField, usedField) + | [ missingField ], usedFields -> + let usedFields = usedFields |> List.map(sprintf "'%s'") + let usedFields = String.concat ", " usedFields + FSComp.SR.tcAnonRecdSingleFieldNameMultipleDifferent(missingField, usedFields) + | missingFields, [ usedField ] -> + let missingFields = missingFields |> List.map(sprintf "'%s'") + let missingFields = String.concat ", " missingFields + FSComp.SR.tcAnonRecdMultipleFieldNameSingleDifferent(missingFields, usedField) + + | missingFields, usedFields -> let missingFields = missingFields |> List.map(sprintf "'%s'") let missingFields = String.concat ", " missingFields let usedFields = usedFields |> List.map(sprintf "'%s'") let usedFields = String.concat ", " usedFields - FSComp.SR.tcAnonRecdMultipleFieldNameDifferent(missingFields, usedFields) + FSComp.SR.tcAnonRecdMultipleFieldNameMultipleDifferent(missingFields, usedFields) ErrorD (ConstraintSolverError(message, csenv.m,m2)) else diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 2aa049d2c79..6e24694c674 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1399,8 +1399,10 @@ tcAnonRecdSingleFieldNameSubset,"This anonymous record is missing field '%s'." tcAnonRecdMultipleFieldsNameSubset,"This anonymous record is missing fields %s." tcAnonRecdSingleFieldNameSuperset,"This anonymous record has an extra field. Remove field '%s'." tcAnonRecdMultipleFieldsNameSuperset,"This anonymous record has extra fields. Remove fields %s." -tcAnonRecdSingleFieldNameDifferent,"This anonymous record should have field '%s', not '%s'." -tcAnonRecdMultipleFieldNameDifferent,"This anonymous record should have fields %s, not %s." +tcAnonRecdSingleFieldNameSingleDifferent,"This anonymous record should have field '%s' but here has field '%s'." +tcAnonRecdSingleFieldNameMultipleDifferent,"This anonymous record should have field '%s' but here has fields %s." +tcAnonRecdMultipleFieldNameSingleDifferent,"This anonymous record should have fields %s; but here has field '%s'." +tcAnonRecdMultipleFieldNameMultipleDifferent,"This anonymous record should have fields %s; but here has fields %s." keywordDescriptionAbstract,"Indicates a method that either has no implementation in the type in which it is declared or that is virtual and has a default implementation." keywordDescriptionAnd,"Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters." keywordDescriptionAs,"Used to give the current class object an object name. Also used to give a name to a whole pattern within a pattern match." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index bbbc9d9c6ac..4817d7bb2ae 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Neplatná deklarace typu anonymního záznamu</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index e9f57851e96..7ebbcd2717b 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Ungültige Deklaration für anonymen Datensatztyp.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index fd35db753ff..e191e8c0abe 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Declaración de tipo de registro anónimo no válido.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 9ee01c2ba9c..4c8b2e90a6e 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Déclaration de type d'enregistrement anonyme non valide.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 01225fd787c..8558c0d9eb0 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1032,9 +1032,14 @@ <target state="translated">La dichiarazione di tipo Record anonimo non è valida.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index c8f54bad7da..ac921b240f5 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1032,9 +1032,14 @@ <target state="translated">匿名レコードの型宣言が無効です。</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 659af604161..67707206a44 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1032,9 +1032,14 @@ <target state="translated">익명 레코드 형식 선언이 잘못되었습니다.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index b96ef38f558..f05b869ae23 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Nieprawidłowa deklaracja typu rekordu anonimowego.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index ffce82a479b..87ae488ca6b 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Declaração inválida de tipo de Registro Anônimo.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index beb51c72706..d228fff221d 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Недопустимое объявление типа анонимной записи.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 4e3e7fa3d34..84ba1c65442 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1032,9 +1032,14 @@ <target state="translated">Anonim Kayıt türü bildirimi geçersiz.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index ae66286695e..a8b0cea8617 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1032,9 +1032,14 @@ <target state="translated">匿名记录类型声明无效。</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 50acbd5369d..e5ac2b85604 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1032,9 +1032,14 @@ <target state="translated">匿名記錄型別宣告無效。</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdMultipleFieldNameDifferent"> - <source>This anonymous record should have fields {0}, not {1}.</source> - <target state="new">This anonymous record should have fields {0}, not {1}.</target> + <trans-unit id="tcAnonRecdMultipleFieldNameMultipleDifferent"> + <source>This anonymous record should have fields {0}; but here has fields {1}.</source> + <target state="new">This anonymous record should have fields {0}; but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdMultipleFieldNameSingleDifferent"> + <source>This anonymous record should have fields {0}; but here has field '{1}'.</source> + <target state="new">This anonymous record should have fields {0}; but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdMultipleFieldsNameSubset"> @@ -1047,9 +1052,14 @@ <target state="new">This anonymous record has extra fields. Remove fields {0}.</target> <note /> </trans-unit> - <trans-unit id="tcAnonRecdSingleFieldNameDifferent"> - <source>This anonymous record should have field '{0}', not '{1}'.</source> - <target state="new">This anonymous record should have field '{0}', not '{1}'.</target> + <trans-unit id="tcAnonRecdSingleFieldNameMultipleDifferent"> + <source>This anonymous record should have field '{0}' but here has fields {1}.</source> + <target state="new">This anonymous record should have field '{0}' but here has fields {1}.</target> + <note /> + </trans-unit> + <trans-unit id="tcAnonRecdSingleFieldNameSingleDifferent"> + <source>This anonymous record should have field '{0}' but here has field '{1}'.</source> + <target state="new">This anonymous record should have field '{0}' but here has field '{1}'.</target> <note /> </trans-unit> <trans-unit id="tcAnonRecdSingleFieldNameSubset"> diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs index 7e2d6a99e40..b5074a29007 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs @@ -72,7 +72,18 @@ let x() = ({| b = 2 |} = {| a = 2 |} ) |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 26, Line 2, Col 37, "This anonymous record should have field 'b', not 'a'.") + (Error 1, Line 2, Col 26, Line 2, Col 37, "This anonymous record should have field 'b' but here has field 'a'.") + ] + + [<Fact>] + let ``Using the wrong anon record with single field 2`` () = + Fsx """ +let x() = ({| b = 2 |} = {| a = 2; c = "" |} ) +""" + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 2, Col 26, Line 2, Col 45, "This anonymous record should have field 'b' but here has fields 'a', 'c'.") ] [<Fact>] @@ -83,7 +94,7 @@ let x() = ({| b = 2; c = 3 |} = {| a = 2 |} ) |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 33, Line 2, Col 44, "This anonymous record should have fields 'b', 'c', not 'a'.") + (Error 1, Line 2, Col 33, Line 2, Col 44, "This anonymous record should have fields 'b', 'c'; but here has field 'a'.") ] [<Fact>] @@ -94,7 +105,7 @@ let x() = ({| b = 2; c = 3 |} = {| a = 2; d = "" |} ) |> compile |> shouldFail |> withDiagnostics [ - (Error 1, Line 2, Col 33, Line 2, Col 52, "This anonymous record should have fields 'b', 'c', not 'a', 'd'.") + (Error 1, Line 2, Col 33, Line 2, Col 52, "This anonymous record should have fields 'b', 'c'; but here has fields 'a', 'd'.") ] [<Fact>] diff --git a/tests/fsharp/typecheck/sigs/neg113.bsl b/tests/fsharp/typecheck/sigs/neg113.bsl index dd3cb324374..c9e74bcc6ec 100644 --- a/tests/fsharp/typecheck/sigs/neg113.bsl +++ b/tests/fsharp/typecheck/sigs/neg113.bsl @@ -1,7 +1,7 @@ neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b', not 'a'. +neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b' but here has field 'a'. neg113.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion diff --git a/tests/fsharp/typecheck/sigs/neg113.vsbsl b/tests/fsharp/typecheck/sigs/neg113.vsbsl index dd3cb324374..c9e74bcc6ec 100644 --- a/tests/fsharp/typecheck/sigs/neg113.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg113.vsbsl @@ -1,7 +1,7 @@ neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b', not 'a'. +neg113.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b' but here has field 'a'. neg113.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion diff --git a/tests/fsharp/typecheck/sigs/neg_anon_1.bsl b/tests/fsharp/typecheck/sigs/neg_anon_1.bsl index c0df80fa44c..1edbabacd8c 100644 --- a/tests/fsharp/typecheck/sigs/neg_anon_1.bsl +++ b/tests/fsharp/typecheck/sigs/neg_anon_1.bsl @@ -1,7 +1,7 @@ neg_anon_1.fs(5,50,5,61): typecheck error FS0001: This anonymous record is missing field 'b'. -neg_anon_1.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b', not 'a'. +neg_anon_1.fs(7,41,7,52): typecheck error FS0001: This anonymous record should have field 'b' but here has field 'a'. neg_anon_1.fs(10,27,10,55): typecheck error FS0059: The type '{| a: int |}' does not have any proper subtypes and need not be used as the target of a static coercion