Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record autocomplete no longer handles type name dot in computation expression #540

Open
nojaf opened this issue Jun 29, 2023 · 1 comment

Comments

@nojaf
Copy link
Contributor

nojaf commented Jun 29, 2023

Hi,

@safesparrow and I encountered a bug with the autocompletion of a new record instance:

    type Entry =
        {
            Idx: int
            FileName: string
            /// Own deps
            DependencyCount: int
            /// Being depended on
            DependentCount: int
            LineCount: int
        }

    let x =
        {
            Entry.{caret}
        }
IComputationExpr
  FSharpTokenType+LbraceTokenElement(type:LBRACE, text:{)
  NewLine(type:NEW_LINE, text:\n) spaces:"\n"
  Whitespace(type:WHITE_SPACE, text:            ) spaces:"            "
  IFromErrorExpr
    IReferenceExpr
      FSharpIdentifierToken(type:IDENTIFIER, text:Entry)
    FSharpTokenType+DotTokenElement(type:DOT, text:.)
  NewLine(type:NEW_LINE, text:\n) spaces:"\n"
  Whitespace(type:WHITE_SPACE, text:        ) spaces:"        "
  FSharpTokenType+RbraceTokenElement(type:RBRACE, text:})

let getRecordEntity (context: FSharpCodeCompletionContext) =
let getRecordFromExprType (expr: IFSharpExpression) =
if isNull expr then None else
let expr = expr.TryGetOriginalRecordExprThroughSandBox()
if isNull expr then None else
let fcsType = expr.TryGetFcsType()
if isNull fcsType || not fcsType.HasTypeDefinition then None else
let fcsEntity = fcsType.TypeDefinition
if not fcsEntity.IsFSharpRecord then None else
Some(fcsEntity, expr)

is not finding the fcsType for the IComputationExpr:

image

We believe this used to work in 2022.1.2. It no longer works for us in 2023.1.3 and 2023.2 EAP 5.

checkResults.GetTypeOfExpression(range) no longer seems to work as expected it seems.

Does this ring a bell? Anything we can do to help?

@auduchinok
Copy link
Collaborator

@nojaf Yes, it looks like a regression, and I can reproduce it. Most likely, it'll require a fix in FCS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants