Skip to content

False positive for SC2154 when dereferencing an associative array inside arithmetic evaluation command #1074

@ngkz

Description

@ngkz

For bugs

  • Rule Id (if any, e.g. SC1000): SC2154
  • My shellcheck version (shellcheck --version or "online"): 0.4.7
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/bash
declare -A test
(( test[foo] ))

Here's what shellcheck currently says:

$ shellcheck myscript
 
Line 3:
(( test[foo] ))
        ^-- SC2154: foo is referenced but not assigned.

$ 

Here's what I wanted or expected to see:

No output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions