intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.54k stars 380 forks source link

LLDB Debugger - shadowed variables not being updated #10227

Open apwojcik opened 1 year ago

apwojcik commented 1 year ago

Environment

Problem description

https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing

While stepping in the debugger through a source code, I noticed the LLDB does not update the shadowed variables. As a result, both the "Variables" tab in the debugger panel and editor inline debugger hints show wrong values. The same is when I use the 'p' command in the LLDB tab. The first occurrence of a variable is displayed in blue as just allocated and a correct value assigned. The later shadowed declarations are not treated as new instantiations, nor even the existing instantiation updated with "new" values. The binary code works correctly. Only the debugger shows the wrong values.

fn foo() {
    ...
    let t = 10;
    ...
    let t = 16;  <-- the debugger still shows '10'
    ..
}

Steps to reproduce

The example from the Rust Book about shadowed variables compiled and stepped in the debugger.

mcmah309 commented 1 year ago

I ran into this same issue. Lead me down the wrong path of looking into some weird reference counting issue, before I figured it out. For now, just going to try and not shadow variables.