SC2154 fails to trigger when assigning function `local globalvar="$globalvar"` (SC2269 also not triggered)
#### For bugs with existing features
- Rule Id (if any, e.g. SC1000): SC2154
- My shellcheck version (`shellcheck --version` or "online"): online
- [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- [x] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
#### Here's a snippet or screenshot that shows the problem:
```bash
#!/bin/bash
f(){
## protect globalvar from mutation in f()
local globalvar="$globalvar"
echo "$globalvar"
}
echo "$globalvar"
```
#### Here's what shellcheck currently says:
```
$ shellcheck myscript
No issues detected!
$
```
#### Here's what I wanted or expected to see:
```
$ shellcheck myscript
[Line 4:]
local globalvar="$globalvar"
^-- [SC2154](https://www.shellcheck.net/wiki/SC2154) (warning): globalvar is referenced but not assigned.
$
```
or at least something like:
```
$ shellcheck myscript
[Line 4:]
local globalvar="$globalvar"
^-- [SC2269](https://www.shellcheck.net/wiki/SC2269) (info): This variable is assigned to itself, so the assignment does nothing.
$
```
or another rule like
```
(warning): This variable is assigned to itself, so the assignment does nothing as there is no global variable assigned.
```
or
```
(warning): This variable is assigned to itself, so the assignment does nothing if there is no globally-available variable, check to ensure.
```
2 条评论