Skip to content

Keyword suggestions shown when accessing members on a anonymous record in a collection #14812

@baronfel

Description

@baronfel

Completion lists for fields of Anonymous Records include keywords in situations where the record is indirectly dereferenced.

Repro steps

Provide the steps required to reproduce the problem:

let x = [ {| Name = "foo" |} ]
x[0]. // <- invoke completions after the dot. Note you get keywords
let anon = x[0]
anon. // <- invoke completions after the dot. Note you only get members of the anonymous record

Expected behavior

Every completion list for properties of an anonymous record should only contain the members of the type.

Actual behavior

Keywords are also suggested.

Known workarounds

Directly bind the anonymous record.

Related information

Originally recorded by @isaacabraham in ionide/ionide-vscode-fsharp#1280, but repros on VS 17.6 previews today, as well as the new Ionide 7.5.0 series (which uses FCS 43.7.200).

@Krzysztof-Cieslak did some debugging and found the following:

The difference in behaviour for those 2 cases comes up from this line dotnet/fsharp@faa115a/src/Compiler/Service/FSharpCheckerResults.fs#L979
tryTcrefOfAppTy g ty in case of anon records returns ValueNone. This is obviously a correct behaviour of tryTcrefOfAppTy but I imagine some different checks should be used, or some different type of data should be passed to CompletionItem

Metadata

Metadata

Assignees

Labels

Area-FCSBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions