molovo / sublime-zsh

Provides native ZSH autocompletion and snippets
https://github.com/molovo/sublime-zsh
MIT License
10 stars 2 forks source link

"Parameter expansion requires a literal" error #3

Open trystero11 opened 2 years ago

trystero11 commented 2 years ago

I have this zsh function defined in my .zshrc file:

# Display keys and values from an associative array
function array() {
  if [[ $# -eq 1 ]]; then
    ARRAY=$1
  else
    echo "usage: ${funcstack[1]} [array]"
    return 1
  fi
  printf '%s -> %s\n' "${(@kPv)ARRAY}" | sort
}

Whenever I save the file, sublime-zsh 0.1.1 jumps to the printf statement and displays a "Parameter expansion requires a literal" error message for the ${(@kPv)ARRAY} parameter expansion. This use of parenthesized parameter expansion flags is valid zsh syntax, per the following sources:

  1. https://itectec.com/superuser/iterating-over-keys-or-k-v-pairs-in-zsh-associative-array/
  2. https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags

It would be great if sublime-zsh could support the use of parameter expansion flags.