diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 293a71a58d6..b60e212e1c9 100755 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -2014,8 +2014,15 @@ let rec ResolveExprLongIdentInModuleOrNamespace (ncenv:NameResolver) nenv (typeN else NoResultsOrUsefulErrors - AtMostOneResult id.idRange ( tyconSearch +++ moduleSearch +++ raze (UndefinedName(depth,FSComp.SR.undefinedNameValueConstructorNamespaceOrType,id,NoPredictions))) - + match tyconSearch +++ moduleSearch with + | Result [] -> + let predictedPossibleTypes = + modref.ModuleOrNamespaceType.AllEntities + |> Seq.map (fun e -> e.DisplayName) + |> Set.ofSeq + + raze (UndefinedName(depth,FSComp.SR.undefinedNameValueConstructorNamespaceOrType,id,predictedPossibleTypes)) + | results -> AtMostOneResult id.idRange results /// An identifier has resolved to a type name in an expression (corresponding to one or more TyconRefs). /// Return either a set of constructors (later refined by overload resolution), or a set of TyconRefs. diff --git a/tests/fsharp/typeProviders/negTests/neg2.bsl b/tests/fsharp/typeProviders/negTests/neg2.bsl index b1bd82c195b..a5d71afcbf7 100644 --- a/tests/fsharp/typeProviders/negTests/neg2.bsl +++ b/tests/fsharp/typeProviders/negTests/neg2.bsl @@ -4,3 +4,7 @@ neg2.fsx(3,59,3,66): typecheck error FS3033: The type provider 'Provider.GoodPro neg2.fsx(3,59,3,66): typecheck error FS3033: The type provider 'Provider.GoodProviderForNegativeTypeTests1' reported an error: Kaboom neg2.fsx(3,59,3,66): typecheck error FS0039: The value, constructor, namespace or type 'TheHype' is not defined + +Maybe you want one of the following: + + TheType \ No newline at end of file diff --git a/tests/fsharp/typecheck/sigs/neg01.bsl b/tests/fsharp/typecheck/sigs/neg01.bsl index 9f25b3af21a..236872237c7 100644 --- a/tests/fsharp/typecheck/sigs/neg01.bsl +++ b/tests/fsharp/typecheck/sigs/neg01.bsl @@ -4,3 +4,15 @@ neg01a.fsi(24,8,25,7): typecheck error FS0913: Types cannot contain nested type neg01a.fs(22,8,23,7): typecheck error FS0913: Types cannot contain nested type definitions neg01b.fs(2,13,2,14): typecheck error FS0039: The value, constructor, namespace or type 'X' is not defined + +Maybe you want one of the following: + + z + + okType + + fieldsInWrongOrder + + missingFieldInSignature + + missingInterfaceInSignature diff --git a/tests/fsharp/typecheck/sigs/neg14.bsl b/tests/fsharp/typecheck/sigs/neg14.bsl index bc17ed5b514..9f9cae40f67 100644 --- a/tests/fsharp/typecheck/sigs/neg14.bsl +++ b/tests/fsharp/typecheck/sigs/neg14.bsl @@ -2,3 +2,15 @@ neg14a.fs(9,6,9,33): typecheck error FS0343: The type 'missingInterfaceInSignature' implements 'System.IComparable' explicitly but provides no corresponding override for 'Object.Equals'. An implementation of 'Object.Equals' has been automatically provided, implemented via 'System.IComparable'. Consider implementing the override 'Object.Equals' explicitly neg14b.fs(2,13,2,14): typecheck error FS0039: The value, constructor, namespace or type 'X' is not defined + +Maybe you want one of the following: + + z + + okType + + fieldsInWrongOrder + + missingFieldInSignature + + missingInterfaceInSignature diff --git a/tests/fsharp/typecheck/sigs/neg15.bsl b/tests/fsharp/typecheck/sigs/neg15.bsl index 5e577283df9..06ca079c08d 100644 --- a/tests/fsharp/typecheck/sigs/neg15.bsl +++ b/tests/fsharp/typecheck/sigs/neg15.bsl @@ -31,10 +31,34 @@ neg15.fs(116,20,116,73): typecheck error FS0072: Lookup on object of indetermina neg15.fs(122,32,122,57): typecheck error FS0039: The value, constructor, namespace or type 'InternalTagOfInternalType' is not defined +Maybe you want one of the following: + + InternalUnionType + + InternalRecordType + + PrivateUnionType + + PrivateRecordType + + PublicRecordType + neg15.fs(128,31,128,61): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. neg15.fs(135,31,135,56): typecheck error FS0039: The value, constructor, namespace or type 'InternalTagOfInternalType' is not defined +Maybe you want one of the following: + + InternalUnionType + + InternalRecordType + + PrivateUnionType + + PrivateRecordType + + PublicRecordType + neg15.fs(141,30,141,60): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. neg15.fs(152,20,152,50): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. diff --git a/tests/fsharp/typecheck/sigs/neg17.bsl b/tests/fsharp/typecheck/sigs/neg17.bsl index a74ee616628..a37d7abf981 100644 --- a/tests/fsharp/typecheck/sigs/neg17.bsl +++ b/tests/fsharp/typecheck/sigs/neg17.bsl @@ -23,6 +23,18 @@ neg17b.fs(17,19,17,47): typecheck error FS0072: Lookup on object of indeterminat neg17b.fs(21,31,21,77): typecheck error FS0039: The value, constructor, namespace or type 'DefaultTagOfUnionTypeWithPrivateRepresentation' is not defined +Maybe you want one of the following: + + UnionTypeWithPrivateRepresentation + + RecordTypeWithPrivateRepresentation + + InternalUnionType + + PrivateUnionType + + PrivateRecordType + neg17b.fs(29,31,29,61): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. neg17b.fs(30,31,30,84): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. diff --git a/tests/fsharpqa/Source/Warnings/SuggestTypesInModule.fs b/tests/fsharpqa/Source/Warnings/SuggestTypesInModule.fs new file mode 100644 index 00000000000..1c5f50ebd66 --- /dev/null +++ b/tests/fsharpqa/Source/Warnings/SuggestTypesInModule.fs @@ -0,0 +1,8 @@ +// #Warnings +//The type 'Lst' is not defined in 'System.Collections.Generic' +//Maybe you want one of the following: +//List + +let x : System.Collections.Generic.Lst = ResizeArray() + +exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst index be9cc19b848..acdf3625fb7 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -13,6 +13,7 @@ SOURCE=AccessOfTypeAbbreviation4.fs # AccessOfTypeAbbreviation4.fs SOURCE=AccessOfTypeAbbreviation5.fs # AccessOfTypeAbbreviation5.fs SOURCE=AccessOfTypeAbbreviation6.fs # AccessOfTypeAbbreviation6.fs + SOURCE=SuggestTypesInModule.fs # SuggestTypesInModule.fs SOURCE=ElseBranchHasWrongType.fs # ElseBranchHasWrongType.fs SOURCE=MatchingMethodWithSameNameIsNotAbstract.fs # MatchingMethodWithSameNameIsNotAbstract.fs SOURCE=NoMatchingAbstractMethodWithSameName.fs # NoMatchingAbstractMethodWithSameName.fs