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
28 changes: 18 additions & 10 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2035,9 +2035,13 @@ let rec ResolveExprLongIdentInModuleOrNamespace (ncenv:NameResolver) nenv (typeN
match tyconSearch +++ moduleSearch +++ unionSearch with
| Result [] ->
let predictedPossibleTypes =
modref.ModuleOrNamespaceType.AllEntities
|> Seq.map (fun e -> e.DisplayName)
|> Set.ofSeq
match ad with
| AccessibleFrom _ ->
modref.ModuleOrNamespaceType.AllEntities
|> Seq.filter (fun e -> IsEntityAccessible ncenv.amap m ad (modref.NestedTyconRef e))
|> Seq.map (fun e -> e.DisplayName)
|> Set.ofSeq
| _ -> Set.empty

raze (UndefinedName(depth,FSComp.SR.undefinedNameValueConstructorNamespaceOrType,id,predictedPossibleTypes))
| results -> AtMostOneResult id.idRange results
Expand Down Expand Up @@ -2413,13 +2417,17 @@ let ResolveTypeLongIdentInTyconRef sink (ncenv:NameResolver) nenv typeNameResInf
tcref

/// Create an UndefinedName error with details
let SuggestTypeLongIdentInModuleOrNamespace depth (modref:ModuleOrNamespaceRef) (id:Ident) =
let SuggestTypeLongIdentInModuleOrNamespace depth (modref:ModuleOrNamespaceRef) amap ad m (id:Ident) =
let predictedPossibleTypes =
modref.ModuleOrNamespaceType.AllEntities
|> Seq.map (fun e -> e.DisplayName)
|> Set.ofSeq

let errorTextF s = FSComp.SR.undefinedNameTypeIn(s,fullDisplayTextOfModRef modref)
match ad with
| AccessibleFrom _ ->
modref.ModuleOrNamespaceType.AllEntities
|> Seq.filter (fun e -> IsEntityAccessible amap m ad (modref.NestedTyconRef e))
|> Seq.map (fun e -> e.DisplayName)
|> Set.ofSeq
| _ -> Set.empty

let errorTextF s = FSComp.SR.undefinedNameTypeIn(s,fullDisplayTextOfModRef modref)
UndefinedName(depth,errorTextF,id,predictedPossibleTypes)

/// Resolve a long identifier representing a type in a module or namespace
Expand All @@ -2431,7 +2439,7 @@ let rec private ResolveTypeLongIdentInModuleOrNamespace (ncenv:NameResolver) (ty
let tcrefs = LookupTypeNameInEntityMaybeHaveArity (ncenv.amap, id.idRange, ad, id.idText, typeNameResInfo.StaticArgsInfo, modref)
match tcrefs with
| _ :: _ -> tcrefs |> CollectResults (fun tcref -> success(resInfo,tcref))
| [] -> raze (SuggestTypeLongIdentInModuleOrNamespace depth modref id)
| [] -> raze (SuggestTypeLongIdentInModuleOrNamespace depth modref ncenv.amap ad m id)
| id::rest ->
let m = unionRanges m id.idRange
let modulSearch =
Expand Down
12 changes: 6 additions & 6 deletions tests/fsharp/typecheck/sigs/neg15.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Maybe you want one of the following:

InternalRecordType

PrivateUnionType
PublicRecordType

PrivateRecordType
Type

PublicRecordType
UnionTypeWithPrivateRepresentation

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.

Expand All @@ -53,11 +53,11 @@ Maybe you want one of the following:

InternalRecordType

PrivateUnionType
PublicRecordType

PrivateRecordType
Type

PublicRecordType
UnionTypeWithPrivateRepresentation

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.

Expand Down
12 changes: 6 additions & 6 deletions tests/fsharp/typecheck/sigs/neg17.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Maybe you want one of the following:

InternalUnionType

PrivateUnionType
InternalRecordType

PrivateRecordType
Type

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.

Expand All @@ -49,9 +49,9 @@ Maybe you want one of the following:

InternalRecordType

PrivateRecordType
Type

PrivateUnionType
InternalUnionType

neg17b.fs(43,30,43,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.

Expand All @@ -65,8 +65,8 @@ Maybe you want one of the following:

InternalRecordType

PrivateRecordType
Type

PrivateUnionType
InternalUnionType

neg17b.fs(54,20,54,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.
Binary file added tests/fsharpqa/Source/Warnings/Repro1548.dll
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/fsharpqa/Source/Warnings/Repro1548.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// #Warnings
//<Expects status="Error" span="(7,15)" id="FS0039">The type 'Type' is not defined in 'B'.</Expects>
//<Expects>Maybe you want one of the following:</Expects>
//<Expects>PublicType</Expects>

type E() =
inherit B.Type()
member x.Y() = ()

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 @@ -29,3 +29,4 @@
SOURCE=RuntimeTypeTestInPattern.fs # RuntimeTypeTestInPattern.fs
SOURCE=RuntimeTypeTestInPattern2.fs # RuntimeTypeTestInPattern2.fs
SOURCE=WarnIfExpressionResultUnused.fs # WarnIfExpressionResultUnused.fs
SOURCE=Repro1548.fs SCFLAGS="-r:Repro1548.dll" # Repro1548.fs