3 ms·
Here's an example that comes to mind: A programmer writing a function refers to a local variable, "status", but thinks they are referring to a global variable.
by theoh 8y ago
Here's an example that comes to mind:
A programmer writing a function refers to a local variable, "status", but thinks they are referring to a global variable. The code works by chance because the variables happen to have the same (fixed) value.
The variable shadowing means that the programmer could quite plausibly be confused and believe that they were accessing the global variable ("justification"). "I know I checked the status variable, like I was supposed to".