zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Paul Wayper <paulway@redhat.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: zsh -n does not detect incorrect associative array declaration
Date: Tue, 22 Mar 2016 17:20:56 -0700	[thread overview]
Message-ID: <CAH+w=7YDbbw_J2G6BJKqi9=MtymqAQo1Zhv-19FGK0RqFnyScA@mail.gmail.com> (raw)
In-Reply-To: <56F1C3D7.6020800@redhat.com>

On Tue, Mar 22, 2016 at 3:14 PM, Paul Wayper <paulway@redhat.com> wrote:
>
> I've discovered that an incorrect associative array declaration in zsh
> isn't detected via 'zsh -n script.zsh', even though it does get flagged
> when the script is executed.

This is not a bug; it's something that it's impossible to check with
the NO_EXEC option.  Consider:

typeset -a array
typeset -A fn
array=( $(some external command) )
fn=( $array )

With NO_EXEC set, the shell is prohibited from executing the $(some
external command) expression, so there is no way to determine how many
elements would be in $array if execution were allowed, and therefore
no way to determine whether an odd number of elements would be present
in the assignment to fn.

Technically, the shell is ALSO prohibited by NO_EXEC from executing
the "typeset" command, and therefore can't possibly know that "fn"
represents an associative array in the first place.

The NO_EXEC option is only useful for the most rudimentary of syntax
checks.  It cannot detect/predict execution-time inaccuracies.


  reply	other threads:[~2016-03-23  2:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 22:14 Paul Wayper
2016-03-23  0:20 ` Bart Schaefer [this message]
2016-03-23  2:28   ` Paul Wayper
2016-03-23  6:40     ` Bart Schaefer
2016-03-23  9:23       ` Peter Stephenson
2016-03-24  2:08         ` Bart Schaefer
2016-03-24  9:46           ` Peter Stephenson
2016-03-24 17:12             ` Bart Schaefer
2016-03-30  6:00       ` Paul Wayper
2016-04-19 13:50 ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7YDbbw_J2G6BJKqi9=MtymqAQo1Zhv-19FGK0RqFnyScA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=paulway@redhat.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).