Skip to content

'Unknown instance kind: closure' when hovering over some functions #2518

Closed

Description

@annagrin

The experimental expression evaluation feature supports evaluating closures, but causes an error displayed in VSCode debug console (see image below).

Repro steps

  • Install flutter
  • Use flutter's example/hello_world, set a breakpoint in
    flutter/packages/flutter/lib/src/widgets/binding.dart:921
  • Add --web-enable-expression-evaluation flag to dart args in launch.json:
   {
       "version": "0.2.0",
       "configurations": [
           {
               "name": "Flutter",
               "request": "launch",
               "type": "dart",
               "args": ["--web-enable-expression-evaluation"],
           }
       ]
   }
  • hover over attachRootWidget

Actual behavior

  • native function text without a body is displayed in pop-up box, and appears to not have a lot of useful information
  • Unknown instance kind: closure error appears in the debug console

Expected behavior

  • some useful representation of the function displayed, for example:
    • maybe full text (if small)
    • or a signature and a few lines
    • or no popup at all
  • no error in display window

image

Activity

  1. changed the title [-]'Unknown instance kind: closure' when hovering over functions[/-] [+]'Unknown instance kind: closure' when hovering over some functions[/+] on Jun 4, 2020
  2. added this to the v3.12.0 milestone on Jun 8, 2020
  3. added
    in debuggingRelates to the debug adapter or process of running debug sessions
    on Jun 8, 2020
  4. DanTup commented on Jun 8, 2020

    @DanTup
    Member

    The reason for the printed warning is that we were trying to render this as a variable (but it has no fields, association, getters, etc.). I've fixed that by treating a Closure as a simple type.

    The reason it shows "function [native code ]" is that we invoke toString() on values when displaying them. In the standard VM, this returns a slightly more useful string Closure: (Widget) => void from Function 'attachRootWidget':.

    {
    	"jsonrpc": "2.0",
    	"result": {
    		"type": "@Instance",
    		"_vmType": "String",
    		"class": {
    			"type": "@Class",
    			"fixedId": true,
    			"id": "classes\/80",
    			"name": "_OneByteString",
    			"_vmName": "_OneByteString@0150898"
    		},
    		"kind": "String",
    		"id": "objects\/100",
    		"length": 60,
    		"valueAsString": "Closure: (Widget) => void from Function 'attachRootWidget':."
    	},
    	"id": "372"
    }
    

    I think the best way to improve this would probably be by handling toString() in the proxy?

    I'd probably prefer VS Code to fall back to the analysis server hover for things like this (since it has the dartdoc etc. in it), but that's not supported when in a debug session.

  5. annagrin commented on Jun 8, 2020

    @annagrin
    Author

    @DanTup thanks for fixing this! I've created an issue on the debugger side to track better printing.

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 debuggingRelates to the debug adapter or process of running debug sessionsis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions