Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:to:subject:mime-version:content-type;
        bh=446wg6qQlO5jozYfj6bY8aK1ekCGIMyPYcLfoA1epKs=;
        b=P0OCqRz1beB4nAeEefD/kLk3MX34sKBCWosvLg03eFQ5M7G7yjwiPFZm/6OK5PTS6S
         Fb0RdJaqV9JiM8+ZRbOeCMPYWAf2xNHsdBkpC5jMsYM+xRHG7/WvxqJ1nZ3TajGy4Zof
         bJhUWOH+EysiuPT8oh9CoTtNlqFWpDtSr7V0G++eOFBI2m9nLupITqO1fx8YsB7ISN/M
         0CmzMC21kOe2xEJGUmDwa846EoGzf1e5JrPCnSh3gOdFMTUhijCL0nTSjCcnjkgwUtjP
         0DooGxGpXTp24ZCHqyt28B1dIKixiGYe1Ii+UEAC5zQf70v7IfsNNrZJpWc4aAvPRpET
         VK2Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:to:subject:mime-version
         :content-type;
        bh=446wg6qQlO5jozYfj6bY8aK1ekCGIMyPYcLfoA1epKs=;
        b=BewajGrCMKUOOZIwqPxxH48gMcRKU3GDmhLPxXPwKQWbOd/qYIsYGDju0eEwkWqEwE
         Q+/4ZBjsqy9zZ9IJxXD21rdyo9ObqDXiAcZMjdCMQ3UxuSHQ4RGwS9szlr4Aivg3FvR2
         S4eIQOI27DoeOTD5WbumocI3vsT8t9HAyNBeUdHgmwPDVfiURh0AatpXNYvdoqC0uZ9f
         Ucw4GShdH/5QXC/9K2Yy655Azl2MlqX1YBFmGG0aYjOpgE4V/qCSV0pc85YOORJkaPwD
         e12jvu60yOQNA6rGjUGeHIVUcv3MjbmjTn1pBuN9Y5LaNTvmGiaItnb7XptZVxN/oQyr
         5chw==
X-Gm-Message-State: AG10YOQeQTZvwNBlOnRLJS3kZu5roxibMPM/4EKMvP6gEGghF006sJDQolG3ZoXK1Svxpw==
X-Received: by 10.98.18.76 with SMTP id a73mr13430112pfj.65.1453572154953;
        Sat, 23 Jan 2016 10:02:34 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160123100311.ZM14575@torch.brasslantern.com>
Date: Sat, 23 Jan 2016 10:03:11 -0800
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Glitch with "eval" and "autoload"
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37745

torch% oops() { eval autoload -X }
torch% oops 
(eval):1: parse error near `"$@"'
torch% functions
'(eval)' () {
        # undefined
        builtin autoload -X
}
oops () {
        eval autoload -X
}


This happens because bin_typeset() gets the name to be autoloaded from
the "scriptname" global, which at the time autoload was invented was not
modified during intervening "eval" and other internal scopes.

The ancient behavior is restored if the "eval_line_no" option is unset.

What's the right way to get the actual function name?  Climbing up the
fstack looking for strcmp(fsptr->name, "(eval)") != 0 seems pretty ugly,
but the "ineval" global isn't sufficient for e.g. "eval eval autoload -X".

