Skip to content

[Debugger] If multiple variables have the same name, VSCode doesn't show one of them. #114757

@fabioz

Description

@fabioz

Version: 1.52.1 (system setup)
Commit: ea3859d
Date: 2020-12-16T16:34:46.910Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363

Steps to Reproduce:

This issue can be reproduced by using the Python extension to debug the following code:

class T:
    def __init__(self, name, value):
        self.name = name
        self.value = value
    def __repr__(self):
        return self.name

td = {T("foo", 24): "bar",
      T("gad", 42): "zooks",
      T("foo", 12): "bur"}

print("Keys: " + str((td.keys())))  
print("Values: " + str((td.values()))) # Breakpoint here

At that point, expanding the td dictionary in the variables view should show 3 entries, yet in only shows 2.

The variables request being returned from debugpy is properly returning a foo entry twice (as expected), but VSCode only shows one entry. The Debug Adapter Protocol doesn't place any restrictions on having unique names for the variables, so, this seems like an issue in VSCode (although if that's not the case and there should be a restriction there, please let me know so that debugpy can be fixed accordingly).

{
     "pydevd_cmd_id": 502,
     "seq": 50,
     "type": "response",
     "request_seq": 20,
     "success": true,
     "command": "variables",
     "body": {
         "variables": [
             {
                 "name": "special variables",
                 "value": "",
                 "type": "",
                 "variablesReference": 8
             },
             {
                 "name": "function variables",
                 "value": "",
                 "type": "",
                 "variablesReference": 9
             },
             {
                 "name": "foo",
                 "value": "'bar'",
                 "type": "str",
                 "evaluateName": "td[foo]",
                 "variablesReference": 0,
                 "presentationHint": {
                     "attributes": [
                         "rawString"
                     ]
                 }
             },
             {
                 "name": "gad",
                 "value": "'zooks'",
                 "type": "str",
                 "evaluateName": "td[gad]",
                 "variablesReference": 0,
                 "presentationHint": {
                     "attributes": [
                         "rawString"
                     ]
                 }
             },
             {
                 "name": "foo",
                 "value": "'bur'",
                 "type": "str",
                 "evaluateName": "td[foo]",
                 "variablesReference": 0,
                 "presentationHint": {
                     "attributes": [
                         "rawString"
                     ]
                 }
             },
             {
                 "name": "len()",
                 "value": "3",
                 "type": "int",
                 "evaluateName": "len(td)",
                 "variablesReference": 0,
                 "presentationHint": {
                     "attributes": [
                         "readOnly"
                     ]
                 }
             }
         ]
     }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions