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

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

Closed
annagrin opened this issue Jun 4, 2020 · 2 comments
Closed

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

annagrin opened this issue Jun 4, 2020 · 2 comments
Labels
in debugger Relates to the debug adapter or process of launching a debug session is bug
Milestone

Comments

@annagrin
Copy link

annagrin commented Jun 4, 2020

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

@annagrin annagrin changed the title 'Unknown instance kind: closure' when hovering over functions 'Unknown instance kind: closure' when hovering over some functions Jun 4, 2020
@DanTup DanTup added this to the v3.12.0 milestone Jun 8, 2020
@DanTup DanTup added in debugger Relates to the debug adapter or process of launching a debug session is bug labels Jun 8, 2020
@DanTup
Copy link
Member

DanTup commented Jun 8, 2020

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.

@annagrin
Copy link
Author

annagrin commented Jun 8, 2020

@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
Labels
in debugger Relates to the debug adapter or process of launching a debug session is bug
Projects
None yet
Development

No branches or pull requests

2 participants