Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@forki
The AtMostResult indicates that this error can produce a message more than once:

Indeed the error messages produced in the failing neg2 testcase looks like this:


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 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AtMostOneResult was moved to line 2025. but thanks for the test report. I will try to fix that.

| 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.
Expand Down
4 changes: 4 additions & 0 deletions tests/fsharp/typeProviders/negTests/neg2.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions tests/fsharp/typecheck/sigs/neg01.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions tests/fsharp/typecheck/sigs/neg14.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 24 additions & 0 deletions tests/fsharp/typecheck/sigs/neg15.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions tests/fsharp/typecheck/sigs/neg17.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions tests/fsharpqa/Source/Warnings/SuggestTypesInModule.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// #Warnings
//<Expects status="Error" id="FS0039">The type 'Lst' is not defined in 'System.Collections.Generic'</Expects>
//<Expects>Maybe you want one of the following:</Expects>
//<Expects>List</Expects>

let x : System.Collections.Generic.Lst = ResizeArray()

exit 0
1 change: 1 addition & 0 deletions tests/fsharpqa/Source/Warnings/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down