Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserve an error message for "obj was inferred" #14642

Merged
merged 11 commits into from
Jan 31, 2023
1 change: 1 addition & 0 deletions src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ type PhasedDiagnostic with
| 3389 -> false // tcBuiltInImplicitConversionUsed - off by default
| 3390 -> false // xmlDocBadlyFormed - off by default
| 3395 -> false // tcImplicitConversionUsedForMethodArg - off by default
| 3559 -> false // typrelNeverRefinedAwayFromTop - off by default
| _ ->
(severity = FSharpDiagnosticSeverity.Info)
|| (severity = FSharpDiagnosticSeverity.Warning && level >= x.WarningLevel)
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1672,4 +1672,5 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form
3555,chkInstanceLetBindingOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed."
3556,chkImplementingInterfacesOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Implementing interfaces is not allowed."
3557,chkAbstractMembersDeclarationsOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Abstract member declarations are not allowed."
3558,chkExplicitFieldsDeclarationsOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed."
3558,chkExplicitFieldsDeclarationsOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed."
3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'."
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">Rozhraní {0} nemůžete implementovat se dvěma instancemi {1} a {2}, protože by se mohly sjednotit.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">Typ {0} nedefinuje pole, konstruktor ani člen {1}.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">Sie können die Schnittstelle "{0}" mit den beiden Instanziierungen "{1}" und "{2}" nicht implementieren, weil sie möglicherweise zusammengeführt werden.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">Der Typ "{0}" definiert nicht das Feld, den Konstruktor oder den Member "{1}".</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">No se puede implementar la interfaz "{0}" con ambas creaciones de instancias, "{1}" y "{2}", porque pueden unificarse.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">El tipo "{0}" no define el campo, constructor o miembro "{1}".</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">Vous ne pouvez pas implémenter l'interface '{0}' avec les deux instanciations '{1}' et '{2}', car elles peuvent s'unifier.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">Le type '{0}' ne définit pas le champ, le constructeur ou le membre '{1}'.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">Non è possibile implementare l'interfaccia '{0}' con le due creazioni di istanze '{1}' e '{2}' perché possono essere unificate.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">Il tipo '{0}' non definisce il campo, il costruttore o il membro '{1}'.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">統合している可能性があるため、'{1}' と '{2}' の 2 つのインスタンス化を含むインターフェイス '{0}' を実装することはできません。</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">型 '{0}' は、フィールド、コンストラクター、またはメンバー '{1}' を定義していません。</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">'{1}' 및 '{2}' 인스턴스화가 포함된 '{0}' 인터페이스를 구현할 수 없습니다. 이 두 인스턴스화가 통합될 수 있기 때문입니다.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">'{0}' 형식은 '{1}' 필드, 생성자 또는 멤버를 정의하지 않습니다.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">Nie możesz zaimplementować interfejsu „{0}” przy użyciu dwóch wystąpień „{1}” i „{2}”, ponieważ mogą one się ujednolicić.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">Typ „{0}” nie definiuje pola, konstruktora lub składowej „{1}”.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">Não é possível implementar a interface '{0}' com as duas instanciações '{1}' e '{2}' porque talvez elas sejam unificadas.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">O tipo '{0}' não define o campo, o construtor ou o membro '{1}'.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">Невозможно реализовать интерфейс "{0}" с двумя созданиями экземпляра "{1}" и "{2}", так как они могут быть объединены.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">Тип "{0}" не определяет поле, конструктор или член "{1}".</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">'{1}' ve '{2}' örnek oluşturmaları birleşebileceğinden '{0}' arabirimini bunlarla birlikte uygulayamazsınız.</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">'{0}' türü; alanı, oluşturucuyu veya '{1}' üyesini tanımlamıyor.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">你无法实现具有两个实例化“{1}”和“{2}”的接口“{0}”,因为它们可能会统一。</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">类型“{0}”未定义字段、构造函数或成员“{1}”。</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@
<target state="translated">因為 '{1}' 和 '{2}' 兩者的具現化可能整合,所以無法將其用於實作介面 '{0}'。</target>
<note />
</trans-unit>
<trans-unit id="typrelNeverRefinedAwayFromTop">
<source>A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</source>
<target state="new">A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'.</target>
<note />
</trans-unit>
<trans-unit id="undefinedNameFieldConstructorOrMemberWhenTypeIsKnown">
<source>The type '{0}' does not define the field, constructor or member '{1}'.</source>
<target state="translated">類型 '{0}' 未定義欄位、建構函式或成員 '{1}'。</target>
Expand Down
10 changes: 5 additions & 5 deletions tests/FSharp.Test.Utilities/Compiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,14 @@ module rec Compiler =

let withLangVersionPreview (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ "--langversion:preview" ] "withLangVersionPreview is only supported on F#" cUnit

Smaug123 marked this conversation as resolved.
Show resolved Hide resolved
let withLangVersion (version: string) (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ $"--langversion:{version}" ] "withLangVersion is only supported on F#" cUnit

let withAssemblyVersion (version:string) (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ $"--version:{version}" ] "withAssemblyVersion is only supported on F#" cUnit

let withWarnOn (cUnit: CompilationUnit) warning : CompilationUnit =
let withWarnOn (warning : int) (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ $"--warnon:{warning}" ] "withWarnOn is only supported for F#" cUnit

let withNoWarn warning (cUnit: CompilationUnit) : CompilationUnit =
Expand Down Expand Up @@ -1088,7 +1088,7 @@ module rec Compiler =
failwith $"PDB file does not exists: {pdbPath}"
| _ -> failwith "Output path is not set, please make sure compilation was successfull."
match result with
| CompilationResult.Success r -> verifyPdbExists r
| CompilationResult.Success r -> verifyPdbExists r
| _ -> failwith "Result should be \"Success\" in order to verify PDB."

let verifyNoPdb (result: CompilationResult): unit =
Expand All @@ -1100,7 +1100,7 @@ module rec Compiler =
failwith $"PDB file exists: {pdbPath}"
| _ -> failwith "Output path is not set, please make sure compilation was successfull."
match result with
| CompilationResult.Success r -> verifyPdbNotExists r
| CompilationResult.Success r -> verifyPdbNotExists r
| _ -> failwith "Result should be \"Success\" in order to verify PDB."

[<AutoOpen>]
Expand Down Expand Up @@ -1369,6 +1369,6 @@ module rec Compiler =
s.Replace("\r", "").Split('\n')
|> Array.map (fun line -> line.TrimEnd())
|> String.concat "\n"

let printSignatures cUnit = printSignaturesImpl None cUnit
let printSignaturesWith pageWidth cUnit = printSignaturesImpl (Some pageWidth) cUnit