FsAutoComplete icon indicating copy to clipboard operation
FsAutoComplete copied to clipboard

The record generator for anonymous records.

Open Krzysztof-Cieslak opened this issue 5 years ago • 4 comments

Sample code:

let x () : {| A: int; B: string  |} = 
    {| A = 123 |}

The error message on the second line: Two anonymous record types have mismatched sets of field names '["A"; "B"]' and '["A"]'. Having info present in error message we should be able to generate stub for missing fields just like in case of normal records

Krzysztof-Cieslak avatar Sep 17 '19 11:09 Krzysztof-Cieslak

I would like to tackle this. Do you know where the stub for the missing fields for regular records is created?

Angr1st avatar Oct 15 '19 23:10 Angr1st

The current record stub generation code is found src/FsAutoComplete.Core/RecordStubGenerator.fs, and the place it's called is the GetRecordStub member in src/FsAutoComplete.Core/Commands.fs. My guess is that shouldGenerateRecordStub needs to be updated to apply to anon records with 'missing' fields, and formatRecord would need to be updated as well.

baronfel avatar Oct 18 '19 16:10 baronfel

Is there a Tool or Documentation to visualize the AST of F# Source Code to improve my understanding of the differences between a RecordExpression and an AnonRecordExpression?

Angr1st avatar Nov 18 '19 21:11 Angr1st

Yep! There's a good one over at https://jindraivanek.gitlab.io/ast-viewer, and a slightly-less good one at sharplab.io.

baronfel avatar Nov 18 '19 21:11 baronfel