microsoft / microsoft/vscode-cpptools
Inconsistent expression evaluation result if type name conflicts with variable name
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Bug type: Debugger
- OS and Version: Windows 10
- VS Code Version: 1.60.1
- C/C++ Extension Version: 1.6.0
Source C code to reproduce (compiled with cl.exe /Zi)
typedef struct foo {
int a;
} foo_t;
foo_t foo;
int main(int argc, char *argv[])
{
return foo.a;
}
Steps to reproduce the behavior:
- Set a breakpoint in main
- Start debugging
- In debug console type
footwice, and the result is different
It seems that the evaluation result of foo for the second time is "class" instead of "data"
The first evaluation result:
foo
-> (C) {"command":"evaluate","arguments":{"expression":"foo","frameId":1000,"context":"repl"},"type":"request","seq":17}
<- (R) {"seq":711,"type":"response","request_seq":17,"success":true,"command":"evaluate","body":{"result":"{a=0 }","type":"foo","presentationHint":{"kind":"data","attributes":["readOnly","static"]},"variablesReference":1003,"evaluateResponseReference":1003}}
The second evaluation result:
-> (C) {"command":"evaluate","arguments":{"expression":"foo","frameId":1000,"context":"repl"},"type":"request","seq":20}
<- (R) {"seq":720,"type":"response","request_seq":20,"success":true,"command":"evaluate","body":{"result":"","presentationHint":{"kind":"class","attributes":["readOnly"]},"variablesReference":0,"evaluateResponseReference":1007}}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in the VS Code debug console with the provided C source and cl.exe /Zi, then inspect how repeated evaluate requests for foo are handled. Compare the first and second responses, especially presentationHint and variablesReference; done means repeated evaluation consistently reports the variable data rather than a class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, typescript, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100