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
21 changes: 14 additions & 7 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
@@ -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
//<Expects status="error" span="(18,13-18,26)" id="FS0039">The field, constructor or member 'GetEnumerator' is not defined$</Expects>
//<Expects status="error" span="(18,13-18,26)" id="FS0039">The field, constructor or member 'GetEnumerator' is not defined</Expects>
//<Expects status="notin" span="(14,21-14,34)" id="FS0034">Module 'M' contains override Foo\.GetEnumerator : unit -> IEnumerator<'T> but its signature specifies member Foo\.GetEnumerator : unit -> IEnumerator<'T> The compiled names differ</Expects>
module M

Expand Down
10 changes: 10 additions & 0 deletions tests/fsharpqa/Source/Warnings/FieldSuggestion.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// #Warnings
//<Expects status="Error" id="FS0039"></Expects>
//<Expects>Maybe you want one of the following:</Expects>
//<Expects>Name</Expects>

type Person = { Name : string; }

let x = { Person.Names = "Isaac" }

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 @@ -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
Expand Down