diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index f5aade84008..91fa74aa552 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -835,10 +835,35 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon (match anonInfo1.Assembly, anonInfo2.Assembly with | ccu1, ccu2 -> if not (ccuEq ccu1 ccu2) then ErrorD (ConstraintSolverError(FSComp.SR.tcAnonRecdCcuMismatch(ccu1.AssemblyName, ccu2.AssemblyName), csenv.m,m2)) else ResultD () ) ++ (fun () -> + if not (anonInfo1.SortedNames = anonInfo2.SortedNames) then - let namesText1 = sprintf "%A" (Array.toList anonInfo1.SortedNames) - let namesText2 = sprintf "%A" (Array.toList anonInfo2.SortedNames) - ErrorD (ConstraintSolverError(FSComp.SR.tcAnonRecdFieldNameMismatch(namesText1, namesText2), csenv.m,m2)) + let (|Subset|Superset|Overlap|CompletelyDifferent|) (first, second) = + let first = Set first + let second = Set second + let secondOnly = Set.toList (second - first) + let firstOnly = Set.toList (first - second) + + if second.IsSubsetOf first then + Subset firstOnly + elif second.IsSupersetOf first then + Superset secondOnly + elif Set.intersect first second <> Set.empty then + Overlap(firstOnly, secondOnly) + else + CompletelyDifferent(Seq.toList first) + + let message = + match anonInfo1.SortedNames, anonInfo2.SortedNames with + | Subset missingFields -> + FSComp.SR.tcAnonRecdFieldNameSubset(string missingFields) + | Superset extraFields -> + FSComp.SR.tcAnonRecdFieldNameSuperset(string extraFields) + | Overlap (missingFields, extraFields) -> + FSComp.SR.tcAnonRecdFieldNameMismatch(string missingFields, string extraFields) + | CompletelyDifferent missingFields -> + FSComp.SR.tcAnonRecdFieldNameDifferent(string missingFields) + + ErrorD (ConstraintSolverError(message, csenv.m,m2)) else ResultD ()) diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index c1ab22ab6ab..0bda612a162 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1352,7 +1352,10 @@ tcGlobalsSystemTypeNotFound,"The system type '%s' was required but no referenced 3214,methodIsNotStatic,"Method or object constructor '%s' is not static" 3215,parsUnexpectedSymbolEqualsInsteadOfIn,"Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?" tcAnonRecdCcuMismatch,"Two anonymous record types are from different assemblies '%s' and '%s'" -tcAnonRecdFieldNameMismatch,"Two anonymous record types have mismatched sets of field names '%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." +tcAnonRecdFieldNameSubset,"This anonymous record does not have enough fields. Add the missing fields %s." +tcAnonRecdFieldNameSuperset,"This anonymous record has too many fields. Remove the extra fields %s." +tcAnonRecdFieldNameDifferent,"This is the wrong anonymous record. It should have the 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." keyworkDescriptionAnd,"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/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index 990037e09db..93d6fdbcdd7 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -47,6 +47,21 @@ Algoritmus {0} není podporovaný. + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Atributy nejde použít pro rozšíření typů. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Dva typy anonymních záznamů mají odlišné sady názvů polí: {0} a {1} + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Dva typy anonymních záznamů mají odlišné sady názvů polí: {0} a {1} diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index a0263a53bd8..3f6d6ed9d8e 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -47,6 +47,21 @@ Algorithmus "{0}" wird nicht unterstützt + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Attribute können nicht auf Typerweiterungen angewendet werden. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Zwei anonyme Datensatztypen weisen die nicht übereinstimmenden Feldnamen "{0}" und "{1}" auf. + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Zwei anonyme Datensatztypen weisen die nicht übereinstimmenden Feldnamen "{0}" und "{1}" auf. diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index ba91cf6400f..b9f3b2eca0c 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -47,6 +47,21 @@ No se admite el algoritmo '{0}' + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Los atributos no se pueden aplicar a las extensiones de tipo. @@ -159,7 +174,7 @@ All branches of a pattern match expression must return values of the same type as the first branch, which here is '{0}'. This branch returns a value of type '{1}'. - Todas las ramas de una expresión de coincidencia de patrón deben devolver valores del mismo tipo. La primera rama devolvió un valor de tipo "{0}", pero esta rama devolvió un valor de tipo "\{1 \}". + All branches of a pattern match expression must return values of the same type as the first branch, which here is '{0}'. This branch returns a value of type '{1}'. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Dos tipos de registros anónimos tienen conjuntos de nombres de campo que no coinciden "{0}" y "{1}" + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Dos tipos de registros anónimos tienen conjuntos de nombres de campo que no coinciden "{0}" y "{1}" diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index d2751124dbd..110db5e63f0 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -47,6 +47,21 @@ Algorithme '{0}' non pris en charge + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Impossible d'appliquer des attributs aux extensions de type. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Deux types d'enregistrement anonyme ont des ensembles de noms de champ incompatibles '{0}' et '{1}' + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Deux types d'enregistrement anonyme ont des ensembles de noms de champ incompatibles '{0}' et '{1}' diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 3dc48e6248b..7e3e657641f 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -47,6 +47,21 @@ L'algoritmo '{0}' non è supportato + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Gli attributi non possono essere applicati a estensioni di tipo. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Due tipi di record anonimo contengono set di nomi di campo '{0}' e '{1}' non corrispondenti + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Due tipi di record anonimo contengono set di nomi di campo '{0}' e '{1}' non corrispondenti diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index 46fc22b3885..91bf01e11ab 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -47,6 +47,21 @@ アルゴリズム '{0}' はサポートされていません + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. 属性を型拡張に適用することはできません。 @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - 2 種類の匿名レコードのフィールド名 '{0}' と '{1}' が一致しません + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + 2 種類の匿名レコードのフィールド名 '{0}' と '{1}' が一致しません diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index 0807084300b..45b89be4326 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -47,6 +47,21 @@ {0}' 알고리즘은 지원되지 않습니다. + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. 형식 확장에 특성을 적용할 수 없습니다. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - 두 무명 레코드 형식의 필드 이름 '{0}' 및 '{1}' 집합이 일치하지 않습니다. + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + 두 무명 레코드 형식의 필드 이름 '{0}' 및 '{1}' 집합이 일치하지 않습니다. diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index e9d92110cbd..e59f8848fac 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -47,6 +47,21 @@ Algorytm „{0}” nie jest obsługiwany + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Atrybutów nie można stosować do rozszerzeń typu. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Dwa typy rekordów anonimowych mają niezgodne zestawy nazw pól „{0}” i „{1}” + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Dwa typy rekordów anonimowych mają niezgodne zestawy nazw pól „{0}” i „{1}” diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index 7d15750bf3b..902b2363080 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -47,6 +47,21 @@ Algoritmo '{0}' sem suporte + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Os atributos não podem ser aplicados às extensões de tipo. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Dois tipos de registro anônimos têm conjuntos incompatíveis de nomes de campos '{0}' e '{1}' + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Dois tipos de registro anônimos têm conjuntos incompatíveis de nomes de campos '{0}' e '{1}' diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index 9d342925266..52dba96f84d 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -47,6 +47,21 @@ Алгоритм "{0}" не поддерживается + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Атрибуты не могут быть применены к расширениям типа. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - Два анонимных типа записей содержат несоответствующие наборы имен полей '{0}' и '{1}' + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + Два анонимных типа записей содержат несоответствующие наборы имен полей '{0}' и '{1}' diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 18b7d759b27..b72a64d5a91 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -47,6 +47,21 @@ {0}' algoritması desteklenmiyor + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. Öznitelikler tür uzantılarına uygulanamaz. @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - İki anonim kayıt türünün eşleşmeyen '{0}' ve '{1}' alan adı kümeleri var + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + İki anonim kayıt türünün eşleşmeyen '{0}' ve '{1}' alan adı kümeleri var diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index d3e0ab4f8ed..45a2abaed4f 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -47,6 +47,21 @@ 不支持算法“{0}” + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. 属性不可应用于类型扩展。 @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - 两个匿名记录类型具有一组不匹配的字段名称“{0}”和“{1}” + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + 两个匿名记录类型具有一组不匹配的字段名称“{0}”和“{1}” diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 41be9e5f870..51b821b96f0 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -47,6 +47,21 @@ 不支援演算法 '{0}' + + This is the wrong anonymous record. It should have the fields {0}. + This is the wrong anonymous record. It should have the fields {0}. + + + + This anonymous record does not have enough fields. Add the missing fields {0}. + This anonymous record does not have enough fields. Add the missing fields {0}. + + + + This anonymous record has too many fields. Remove the extra fields {0}. + This anonymous record has too many fields. Remove the extra fields {0}. + + Attributes cannot be applied to type extensions. 屬性無法套用到類型延伸模組。 @@ -7128,8 +7143,8 @@ - Two anonymous record types have mismatched sets of field names '{0}' and '{1}' - 兩個匿名的記錄類型有兩組不相符的欄位名稱 '{0}' 和 '{1}' + This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}. + 兩個匿名的記錄類型有兩組不相符的欄位名稱 '{0}' 和 '{1}' diff --git a/tests/fsharp/typecheck/sigs/neg113.bsl b/tests/fsharp/typecheck/sigs/neg113.bsl index b9f0190c63b..b779344fda7 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: Two anonymous record types have mismatched sets of field names '["a"; "b"]' and '["a"]' +neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record does not have enough fields. Add the missing fields [b]. -neg113.fs(7,41,7,52): typecheck error FS0001: Two anonymous record types have mismatched sets of field names '["b"]' and '["a"]' +neg113.fs(7,41,7,52): typecheck error FS0001: This is the wrong anonymous record. It should have the fields [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 b9f0190c63b..b779344fda7 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: Two anonymous record types have mismatched sets of field names '["a"; "b"]' and '["a"]' +neg113.fs(5,50,5,61): typecheck error FS0001: This anonymous record does not have enough fields. Add the missing fields [b]. -neg113.fs(7,41,7,52): typecheck error FS0001: Two anonymous record types have mismatched sets of field names '["b"]' and '["a"]' +neg113.fs(7,41,7,52): typecheck error FS0001: This is the wrong anonymous record. It should have the fields [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 3e75d81144c..018f51e3a3c 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: Two anonymous record types have mismatched sets of field names '["a"; "b"]' and '["a"]' +neg_anon_1.fs(5,50,5,61): typecheck error FS0001: This anonymous record does not have enough fields. Add the missing fields [b]. -neg_anon_1.fs(7,41,7,52): typecheck error FS0001: Two anonymous record types have mismatched sets of field names '["b"]' and '["a"]' +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(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