zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: typeset -T crash
Date: Sun, 9 Aug 2015 18:56:10 +0100	[thread overview]
Message-ID: <20150809185610.4ee4d3e5@ntlworld.com> (raw)
In-Reply-To: <CAHYJk3Thbi1rbT02_QzSMjjiqpSVQ3awtEkGi0nYHrY8ZbAPnA@mail.gmail.com>

On Wed, 5 Aug 2015 19:59:31 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> typeset -T i j k; typeset -T j i k

Surely the right fix is something like this?

pws

diff --git a/Src/builtin.c b/Src/builtin.c
index 34bad03..c63be7e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2674,7 +2674,9 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
 	    && (locallevel == pm->level || !(on & PM_LOCAL))) {
 	    if (pm->node.flags & PM_TIED) {
 		unqueue_signals();
-		if (!strcmp(asg->name, pm->ename)) {
+		if (PM_TYPE(pm->node.flags) != PM_SCALAR) {
+		    zwarnnam(name, "already tied as non-scalar: %s", asg0.name);
+		} else if (!strcmp(asg->name, pm->ename)) {
 		    /*
 		     * Already tied in the fashion requested.
 		     */
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 0a9e253..c7d506a 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1069,6 +1069,11 @@
 >a:b a b
 >x:y:z
 
+  typeset -T tied1 tied2 +
+  typeset -T tied2 tied1 +
+1:Attempts to swap tied variables are safe but futile
+?(eval):typeset:2: already tied as non-scalar: tied2
+
   string='look for a match in here'
   if [[ ${string%%(#b)(match)*} = "look for a " ]]; then
     print $match[1] $mbegin[1] $mend[1] $string[$mbegin[1],$mend[1]]


  parent reply	other threads:[~2015-08-09 17:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05 17:59 Mikael Magnusson
2015-08-05 20:04 ` Bart Schaefer
2015-08-05 20:41   ` Mikael Magnusson
2015-08-06  0:35     ` Bart Schaefer
2015-08-09 17:56 ` Peter Stephenson [this message]
2015-08-09 19:31   ` Mikael Magnusson

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=20150809185610.4ee4d3e5@ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).