diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 293a71a58d..8b11d0128c 100755 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -1894,15 +1894,22 @@ let rec ResolveLongIdentInTypePrim (ncenv:NameResolver) nenv lookupKind (resInfo success(resInfo,Item.RecdField(rfinfo),rest) | _ -> let pinfos = ExtensionPropInfosOfTypeInScope ncenv.InfoReader nenv (optFilter, ad) m typ - if nonNil pinfos && (match lookupKind with LookupKind.Expr -> true | _ -> false) then + if nonNil pinfos && lookupKind = LookupKind.Expr then success (resInfo,Item.Property (nm,pinfos),rest) else - let minfos = ExtensionMethInfosOfTypeInScope ncenv.InfoReader nenv optFilter m typ - if nonNil minfos && (match lookupKind with LookupKind.Expr -> true | _ -> false) then - success (resInfo,Item.MakeMethGroup (nm,minfos),rest) - + if nonNil minfos && lookupKind = LookupKind.Expr then + success (resInfo,Item.MakeMethGroup (nm,minfos),rest) elif isTyparTy g typ then raze (IndeterminateType(unionRanges m id.idRange)) - else raze (UndefinedName (depth,FSComp.SR.undefinedNameFieldConstructorOrMember, id,NoPredictions)) + else + let predictedLabels = + if isRecdTy g typ then + ncenv.InfoReader.GetRecordOrClassFieldsOfType(None, ad, m, typ) + |> List.map (fun r -> r.Name) + |> Set.ofSeq + else + Set.empty + + raze (UndefinedName (depth,FSComp.SR.undefinedNameFieldConstructorOrMember, id, predictedLabels)) let nestedSearchAccessible = let nestedTypes = GetNestedTypesOfType (ad, ncenv, Some nm, (if isNil rest then typeNameResInfo.StaticArgsInfo else TypeNameResolutionStaticArgsInfo.Indefinite), true, m) typ @@ -2579,7 +2586,7 @@ let ResolveFieldPrim (ncenv:NameResolver) nenv ad typ (mp,id:Ident) allFields = match ncenv.InfoReader.TryFindRecdOrClassFieldInfoOfType(id.idText,m,typ) with | Some (RecdFieldInfo(_,rfref)) -> [ResolutionInfo.Empty, FieldResolution(rfref,false)] | None -> - let typeName = NicePrint.minimalStringOfType nenv.eDisplayEnv typ + let typeName = NicePrint.minimalStringOfType nenv.eDisplayEnv typ if isRecdTy g typ then // record label doesn't belong to record type -> predict other labels of same record error(Error(SuggestOtherLabelsOfSameRecordType nenv typeName id allFields,m)) diff --git a/tests/fsharpqa/Source/Conformance/Signatures/SignatureConformance/E_StructWithNameConflict02.fsi b/tests/fsharpqa/Source/Conformance/Signatures/SignatureConformance/E_StructWithNameConflict02.fsi index 04d1d693c4..76a9a314b5 100644 --- a/tests/fsharpqa/Source/Conformance/Signatures/SignatureConformance/E_StructWithNameConflict02.fsi +++ b/tests/fsharpqa/Source/Conformance/Signatures/SignatureConformance/E_StructWithNameConflict02.fsi @@ -1,6 +1,6 @@ // #Conformance #Signatures #Structs #Regression // Regression for Dev11:137942, structs used to not give errors on when member names conflicted with interface members -//The field, constructor or member 'GetEnumerator' is not defined$ +//The field, constructor or member 'GetEnumerator' is not defined //Module 'M' contains override Foo\.GetEnumerator : unit -> IEnumerator<'T> but its signature specifies member Foo\.GetEnumerator : unit -> IEnumerator<'T> The compiled names differ module M diff --git a/tests/fsharpqa/Source/Warnings/FieldSuggestion.fs b/tests/fsharpqa/Source/Warnings/FieldSuggestion.fs new file mode 100644 index 0000000000..6931f36f98 --- /dev/null +++ b/tests/fsharpqa/Source/Warnings/FieldSuggestion.fs @@ -0,0 +1,10 @@ +// #Warnings +// +//Maybe you want one of the following: +//Name + +type Person = { Name : string; } + +let x = { Person.Names = "Isaac" } + +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 be9cc19b84..7266973a4a 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -19,6 +19,7 @@ SOURCE=MissingExpressionAfterLet.fs # MissingExpressionAfterLet.fs SOURCE=AssignmentOnImmutable.fs # AssignmentOnImmutable.fs SOURCE=SuggestFieldsInCtor.fs # SuggestFieldsInCtor.fs + SOURCE=FieldSuggestion.fs # FieldSuggestion.fs SOURCE=RefCellInsteadOfNot.fs # RefCellInsteadOfNot.fs SOURCE=RefCellInsteadOfNot2.fs # RefCellInsteadOfNot2.fs SOURCE=UpcastInsteadOfDowncast.fs # UpcastInsteadOfDowncast.fs