Skip to content

"Cannot read properties of undefined (reading 'label')" during code completion #4451

Closed

Description

@DanTup

Reported in #4421 by @incendial:

2023-03-03 17:49:00.451 [error] [Dart-Code.dart-code] provider FAILED
2023-03-03 17:49:00.451 [error] TypeError: Cannot read properties of undefined (reading 'label')
	at shouldTriggerCompletionAgain (/Users/dimannich/.vscode/extensions/dart-code.dart-code-3.60.1/out/dist/extension.js:5474:39)
	at LspAnalyzer.<anonymous> (/Users/dimannich/.vscode/extensions/dart-code.dart-code-3.60.1/out/dist/extension.js:5556:25)
	at Generator.next (<anonymous>)
	at fulfilled (/Users/dimannich/.vscode/extensions/dart-code.dart-code-3.60.1/out/dist/extension.js:5381:58)
	at runNextTicks (node:internal/process/task_queues:61:5)
	at process.processImmediate (node:internal/timers:437:9)

Something is causing code completions without labels.

Activity

  1. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Mar 22, 2023
  2. added this to the v3.62.0 milestone on Mar 22, 2023
  3. DanTup commented on Mar 22, 2023

    @DanTup
    MemberAuthor

    I can reproduce this when invoking completion here:

    Screenshot 2023-03-22 at 13 30 38

    If I rig the server to throw when this happens, I get this:

    Empty label for {"kind"::"INVOCATION","relevance"::508,"completion"::"","selectionOffset"::0,"selectionLength"::0,"isDeprecated"::false,"isPotential"::false,"element"::{"kind"::"EXTENSION","name"::"","location"::{"file"::"/Users/danny/Dev/TestStuff/dart-code-metrics/lib/src/analyzers/lint_analyzer/rules/rules_list/use_setstate_synchronously/helpers.dart","offset"::-1,"length"::0,"startLine"::1,"startColumn"::0,"endLine"::1,"endColumn"::0},"flags"::16}}
    #0      toCompletionItem (package::analysis_server/src/lsp/mapping.dart::983::5)
    #1      CompletionHandler._getServerDartItems.suggestionToCompletionItem (package::analysis_server/src/lsp/handlers/handler_completion.dart::475::16)
    #2      MappedIterator.moveNext (dart::_internal/iterable.dart::393::20)
    #3      new _GrowableList._ofOther (dart::core-patch/growable_array.dart::202::26)
    #4      new _GrowableList.of (dart::core-patch/growable_array.dart::152::26)
    #5      new List.of (dart::core-patch/array_patch.dart::47::28)
    #6      Iterable.toList (dart::core/iterable.dart::470::12)
    #7      CompletionHandler._getServerDartItems.<anonymous closure> (package::analysis_server/src/lsp/handlers/handler_completion.dart::501::14)
    

    There's an unnamed extension in that file (extension on BinaryExpression) which I suspect is the trigger.

  4. DanTup commented on Mar 22, 2023

    @DanTup
    MemberAuthor
  5. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Mar 22, 2023
  6. DanTup commented on Mar 22, 2023

    @DanTup
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions