title: Using "declare" in Zsh
body: <p>I am following this thread: <a href="https://stackoverflow.com/a/19742842/5057251">https://stackoverflow.com/a/19742842/5057251</a>
  for typeset (or declare) in ZSH, not BASH.</p>
  
  <pre class="lang-sh prettyprint-override"><code>#Declare (or typeset) an array of integers
  #declare -ai int_array
  typeset -ai int_array
  int_array=(1 2 3)
  echo "${int_array[@]}"
  </code></pre>
  
  <p>Then </p>
  
  <pre class="lang-sh prettyprint-override"><code># Attempt to change 1st element to string. (expect to fail)
  int_array[1]="Should fail" || echo "error: ${LINENO}"
  echo "${int_array[@]}"
  </code></pre>
  
  <p>Bash finds the error, gracefully reports error and lineno, prints:</p>
  
  <pre><code>1 2 3
  </code></pre>
  
  <p>But Zsh accepts, prints:</p>
  
  <pre><code>Should fail 2 3
  </code></pre>
  
  <p>Not sure why different.</p>