diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index deeb8d5daf..5778f3dd92 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -161,7 +161,6 @@ FieldNotContainedMutablesDiffer,"The module contains the field\n %s \nbut FieldNotContainedLiteralsDiffer,"The module contains the field\n %s \nbut its signature specifies\n %s \nThe 'literal' modifiers differ" FieldNotContainedTypesDiffer,"The module contains the field\n %s \nbut its signature specifies\n %s \nThe types differ" 331,typrelCannotResolveImplicitGenericInstantiation,"The implicit instantiation of a generic construct at or near this point could not be resolved because it could resolve to multiple unrelated types, e.g. '%s' and '%s'. Consider using type annotations to resolve the ambiguity" -332,typrelCannotResolveAmbiguityInOverloadedOperator,"Could not resolve the ambiguity inherent in the use of the operator '%s' at or near this program point. Consider using type annotations to resolve the ambiguity." 333,typrelCannotResolveAmbiguityInPrintf,"Could not resolve the ambiguity inherent in the use of a 'printf'-style format string" 334,typrelCannotResolveAmbiguityInEnum,"Could not resolve the ambiguity in the use of a generic construct with an 'enum' constraint at or near this position" 335,typrelCannotResolveAmbiguityInDelegate,"Could not resolve the ambiguity in the use of a generic construct with a 'delegate' constraint at or near this position" diff --git a/src/fsharp/TypeRelations.fs b/src/fsharp/TypeRelations.fs index f72071b900..4011bda25d 100755 --- a/src/fsharp/TypeRelations.fs +++ b/src/fsharp/TypeRelations.fs @@ -141,8 +141,7 @@ let ChooseTyparSolutionAndRange (g: TcGlobals) amap (tp:Typar) = match tpc with | TyparConstraint.CoercesTo(x,m) -> join m x,m - | TyparConstraint.MayResolveMember(TTrait(_,nm,_,_,_,_),m) -> - errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInOverloadedOperator(DemangleOperatorName nm),m)) + | TyparConstraint.MayResolveMember(TTrait(_,_,_,_,_,_),m) -> maxSoFar,m | TyparConstraint.SimpleChoice(_,m) -> errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInPrintf(),m)) diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index de8bf46810..9cdaa6a18f 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -802,11 +802,6 @@ Nepovedlo se přeložit implicitní vytvoření instance obecného konstruktoru na této pozici nebo blízko ní, protože by se dala přeložit na víc nesouvisejících typů, třeba {0} a {1}. Tuto nejednoznačnost můžete vyřešit pomocí poznámek typu. - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Nepovedlo se vyřešit nejednoznačnost vyplývající z použití operátoru {0} na tomto místě v programu nebo blízko něho. Tuto nejednoznačnost můžete vyřešit pomocí poznámek typu. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Nepovedlo se vyřešit nejednoznačnost vyplývající z použití formátovacího řetězce ve stylu printf. diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 871682009f..7c73818288 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -802,11 +802,6 @@ Die implizite Instanziierung eines generischen Konstrukts an diesem Punkt oder in dessen Umgebung konnte nicht aufgelöst werden, weil sie zu mehreren unzusammenhängenden Typen aufgelöst werden könnte, z.B. "{0}" und "{1}". Verwenden Sie Typanmerkungen, um die Mehrdeutigkeit aufzulösen. - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Die inhärente Mehrdeutigkeit bei der Verwendung des {0}-Operators an diesem Programmpunkt oder in dessen Umgebung konnte nicht aufgelöst werden. Verwenden Sie Typanmerkungen, um die Mehrdeutigkeit aufzulösen. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Die inhärente Mehrdeutigkeit bei der Verwendung einer printf-Formatzeichenfolge konnte nicht aufgelöst werden. diff --git a/src/fsharp/xlf/FSComp.txt.en.xlf b/src/fsharp/xlf/FSComp.txt.en.xlf index f5c18a3b87..5e6faa804c 100644 --- a/src/fsharp/xlf/FSComp.txt.en.xlf +++ b/src/fsharp/xlf/FSComp.txt.en.xlf @@ -802,11 +802,6 @@ The implicit instantiation of a generic construct at or near this point could not be resolved because it could resolve to multiple unrelated types, e.g. '{0}' and '{1}'. Consider using type annotations to resolve the ambiguity - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Could not resolve the ambiguity inherent in the use of a 'printf'-style format string diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index 5cd8334aab..f9490c4c92 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -802,11 +802,6 @@ No se pudo resolver la creación de instancia implícita de una construcción genérica en este punto o cerca de él porque se podía resolver en varios tipos no relacionados; por ejemplo, '{0}' y '{1}'. Considere el uso de anotaciones de tipo para resolver la ambigüedad. - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - No se pudo resolver la ambigüedad inherente en el uso del operador '{0}' en este punto del programa o cerca de él. Considere el uso de anotaciones de tipo para resolver la ambigüedad. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string No se pudo resolver la ambigüedad inherente en el uso de una cadena de formato de tipo 'printf'. diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index be6faae997..1219b7d427 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -802,11 +802,6 @@ Impossible de résoudre l'instanciation implicite d'une construction générique à cet emplacement ou à proximité, car elle peut être résolue en plusieurs types non liés, par exemple '{0}' et '{1}'. Utilisez des annotations de type pour résoudre l'ambigüité - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Impossible de résoudre l'ambigüité inhérente à l'utilisation de l'opérateur '{0}' à cet emplacement du programme ou à proximité. Utilisez des annotations de type pour résoudre l'ambigüité. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Impossible de résoudre l'ambigüité inhérente à l'utilisation d'une chaîne de format de style 'printf' diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 2018408d5b..6090bc62dd 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -802,11 +802,6 @@ Non è stato possibile risolvere la creazione di istanza implicita di un costrutto generico in questo punto o in prossimità di esso perché la risoluzione potrebbe restituire più tipi non correlati, ad esempio '{0}' e '{1}'. Provare a usare annotazioni di tipo per risolvere l'ambiguità - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Non è stato possibile risolvere l'ambiguità relativa all'uso dell'operatore '{0}' in questo punto del programma o in prossimità di esso. Provare invece a risolvere l'ambiguità usando annotazioni di tipo. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Non è stato possibile risolvere l'ambiguità relativa all'uso della stringa di formato di stile 'printf' diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index ccfa62d2ec..96e27fe596 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -802,11 +802,6 @@ この場所またはその付近にあるジェネリック コンストラクトの暗黙的なインスタンス化を解決できませんでした。これは、関連性のない複数の型に解決される可能性があるためです (たとえば、'{0}' と '{1}')。あいまいさを解決するために、型の注釈を使用してください。 - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - このプログラム ポイント、またはその付近にある演算子 '{0}' の使用に関して、あいまいな継承を解決できませんでした。あいまいさを解決するために、型の注釈を使用してください。 - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string 'printf' 形式の書式指定文字列の使用に関して、あいまいな継承を解決できませんでした diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index 34f6c74a68..f1da0d44ac 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -802,11 +802,6 @@ 관련되지 않은 여러 형식(예: '{0}'과(와) '{1}')으로 확인될 수 있으므로 이 지점 또는 이 지점 근처에서 제네릭 구문의 암시적 인스턴스를 확인할 수 없습니다. 형식 주석을 사용하여 모호성을 해결하세요. - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - ’{0}' 연산자 사용과 관련하여 이 프로그램 지점 또는 이 지점 근처에서 본질적으로 발생하는 모호성을 해결할 수 없습니다. 형식 주석을 사용하여 모호성을 해결하세요. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string 'printf' 스타일의 서식 문자열 사용과 관련하여 본질적으로 발생하는 모호성을 해결할 수 없습니다. diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index bc8bef8eeb..434d400d47 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -802,11 +802,6 @@ Nie można rozpoznać niejawnego wystąpienia konstrukcji ogólnej w tym miejscu lub w jego pobliżu, ponieważ może to spowodować powstanie wielu niepowiązanych typów, na przykład „{0}” i „{1}”. Rozważ użycie adnotacji typu w celu rozwiązania niejednoznaczności - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Nie można rozwiązać odziedziczonej niejednoznaczności w przypadku użycia operatora „{0}” w tym punkcie programu lub w jego pobliżu. Rozważ użycie adnotacji typu w celu rozwiązania niejednoznaczności. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Nie można usunąć niejednoznaczności spowodowanej użyciem ciągu formatu „printf” diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index ecdb4da2f4..683bb23f5a 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -802,11 +802,6 @@ A instanciação implícita do constructo genérico neste ponto ou próximo a ele não pode ser resolvida porque ele conseguiu resolver tipos não relacionados múltiplos, por exemplo '{0}' e '{1}'. Considere usar anotações de tipo para resolver a ambiguidade - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Não foi possível resolver a ambiguidade no uso de um operador '{0}' neste ponto do programa ou próximo a ele. Considere usar anotações de tipo para resolver a ambiguidade. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Não foi possível resolver a ambiguidade inerente ao uso de uma cadeia de caracteres com formato de estilo 'printf' diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index 7ee89b1cf8..0e874b1122 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -802,11 +802,6 @@ Неявное создание экземпляров базовой конструкции в данной точке или рядом с ней не может быть разрешено, так как тогда возможно разрешение в несколько несвязанных типов, напр. "{0}" и "{1}". Рекомендуется использовать аннотации типа для решения неоднозначности - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - Не удалось разрешить неоднозначность, унаследованную в использовании оператора "{0}" в данной точке программы или рядом с ней. Рекомендуется использовать аннотации типа для решения неоднозначности. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string Не удалось разрешить неоднозначность, унаследованную в использовании строки формата вида "printf" diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 264cf6ee93..8f5c3e3e6a 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -802,11 +802,6 @@ Genel yapının bu konumda veya yakınında örtük olarak örneklenmesi çözümlenemedi, çünkü ilişkisiz birden çok türe çözümlenebiliyordu, örn. '{0}' ve '{1}'. Belirsizliği çözümlemek için tür ek açıklamaları kullanmayı düşünün - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - '{0}' işlecinin bu program noktasında veya yakınında kullanılmasında bulunan belirsizlik çözümlenemedi. Bu belirsizliği çözmek için tür ek açıklamaları kullanmayı düşünün. - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string 'printf' stilindeki biçim dizesinin kullanılmasına bulunan belirsizlik çözümlenemedi. diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index 1704c51829..25518d7ef9 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -802,11 +802,6 @@ 未能解析在此点或其附近进行的泛型构造的隐式实例化,因为它可以解析为多个不相关的类型,例如“{0}”和“{1}”。请考虑使用类型批注来解析此多义性 - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - 未能解析在此程序点或其附近使用运算符“{0}”所产生的固有多义性。请考虑使用类型批注来解析此多义性。 - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string 未能解析使用“printf”样式的格式字符串所产生的固有多义性 diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 3e6b4bcd78..8ffd7432fe 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -802,11 +802,6 @@ 無法解決在這個點或附近的泛型建構的隱含具現化,因為它可能解析成多個不相關的類型,例如 '{0}' 和 '{1}'。請考慮使用類型註釋來解決模稜兩可 - - Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity. - 無法解決在這個程式點或附近使用運算子 '{0}' 時固有的模稜兩可。請考慮使用型別註解來解決模稜兩可。 - - Could not resolve the ambiguity inherent in the use of a 'printf'-style format string 無法解決使用 'printf' 樣式的格式字串時固有的模稜兩可 diff --git a/tests/fsharp/core/subtype/test.fsx b/tests/fsharp/core/subtype/test.fsx index 69edfb2ff1..046a8b6c72 100644 --- a/tests/fsharp/core/subtype/test.fsx +++ b/tests/fsharp/core/subtype/test.fsx @@ -1791,6 +1791,44 @@ module SRTPFix = printfn "%A" <| replace 'q' (test("HI")) *) + +module SRTPFixAmbiguity = + // Mini Repro from FSharpPlus https://github.com/gusty/FSharpPlus + type Id<'t>(v:'t) = member __.getValue = v + type Interface<'t> = abstract member getValue : 't + + type Monad = + static member inline InvokeReturn (x:'T) : '``Monad<'T>`` = + let inline call (mthd : ^M, output : ^R) = ((^M or ^R) : (static member Return: _ -> _) output) + call (Unchecked.defaultof, Unchecked.defaultof<'``Monad<'T>``>) x + static member Return (_:Interface<'a>) = fun (_:'a) -> Unchecked.defaultof> : Interface<'a> + static member Return (_:seq<'a> ) = fun x -> Seq.singleton x : seq<'a> + static member Return (_:option<'a> ) = fun x -> Some x : option<'a> + static member Return (_:Id<'a> ) = fun x -> Id x : Id<'a> + + static member inline InvokeBind (source : '``Monad<'T>``) (binder : 'T -> '``Monad<'U>``) : '``Monad<'U>`` = + let inline call (mthd : 'M, input : 'I, _output : 'R, f) = ((^M or ^I or ^R) : (static member Bind: _*_ -> _) input, f) + call (Unchecked.defaultof, source, Unchecked.defaultof<'``Monad<'U>``>, binder) + static member Bind (source : Interface<'T>, f : 'T -> Interface<'U>) = f source.getValue : Interface<'U> + static member Bind (source : seq<'T> , f : 'T -> seq<'U> ) = Seq.collect f source : seq<'U> + static member Bind (source : Id<'T> , f : 'T -> Id<'U> ) = f source.getValue : Id<'U> + static member Bind (source :option<'T> , f : 'T -> _ ) = Option.bind f source : option<'U> + + let inline result (x:'T) = Monad.InvokeReturn x :'``Monad<'T>`` + let inline (>>=) (x:'``Monad<'T>``) (f:'T->'``Monad<'U>``) = Monad.InvokeBind x f :'``Monad<'U>`` + + type ReaderT<'R,'``monad<'T>``> = ReaderT of ('R -> '``monad<'T>``) + let runReaderT (ReaderT x) = x : 'R -> '``Monad<'T>`` + type ReaderT<'R,'``monad<'T>``> with + static member inline Return _ = fun (x : 'T) -> ReaderT (fun _ -> result x) : ReaderT<'R, '``Monad<'T>``> + static member inline Bind (ReaderT (m:_->'``Monad<'T>``), f:'T->_) = ReaderT (fun r -> m r >>= (fun a -> runReaderT (f a) r)) : ReaderT<'R, '``Monad<'U>``> + + + let test1 : ReaderT> = ReaderT result >>= result + let test2 : ReaderT> = ReaderT result >>= result + let test3 : ReaderT> = ReaderT result >>= result + + // See https://github.com/Microsoft/visualfsharp/issues/4040 module InferenceRegression4040 = type Foo() = diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/StaticLetDoDeclarations/E_LexicalScoping01.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/StaticLetDoDeclarations/E_LexicalScoping01.fs index c6f4b62c99..8105efe3e0 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/StaticLetDoDeclarations/E_LexicalScoping01.fs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/StaticLetDoDeclarations/E_LexicalScoping01.fs @@ -1,9 +1,8 @@ // #Regression #Conformance #ObjectOrientedTypes #Classes #LetBindings // Scoping: // identifier introduced by let is local -//The value, namespace, type or module 'm' is not defined -//The value, namespace, type or module 'n' is not defined -//Could not resolve the ambiguity inherent in the use of the operator '\( \+ \)' at or near this program point\. Consider using type annotations to resolve the ambiguity\.$ +//The value, namespace, type or module 'm' is not defined +//The value, namespace, type or module 'n' is not defined type C() = class static let mutable m = [1;2;3] diff --git a/tests/fsharpqa/Source/Conformance/TypesAndTypeConstraints/CheckingSyntacticTypes/E_MemberConstraint01.fs b/tests/fsharpqa/Source/Conformance/TypesAndTypeConstraints/CheckingSyntacticTypes/E_MemberConstraint01.fs index 70e8ea65a9..113d7dbe1b 100644 --- a/tests/fsharpqa/Source/Conformance/TypesAndTypeConstraints/CheckingSyntacticTypes/E_MemberConstraint01.fs +++ b/tests/fsharpqa/Source/Conformance/TypesAndTypeConstraints/CheckingSyntacticTypes/E_MemberConstraint01.fs @@ -1,6 +1,5 @@ // #Conformance #TypeConstraints -//Could not resolve the ambiguity inherent in the use of the operator 'someFunc' at or near this program point\. Consider using type annotations to resolve the ambiguity\.$ -//Type constraint mismatch when applying the default type 'obj' for a type inference variable\. The type 'obj' does not support the operator 'someFunc' Consider adding further type constraints$ +//Type constraint mismatch when applying the default type 'obj' for a type inference variable\. The type 'obj' does not support the operator 'someFunc' Consider adding further type constraints$ let testFunc (a : ^x) = (^x : (static member someFunc : unit -> ^x) ())