zsh-workers
 help / color / mirror / code / Atom feed
* Bug with associative arrays(?)
@ 1999-02-02  8:04 Sven Wischnowsky
  1999-02-02  8:36 ` Peter Stephenson
  1999-02-02  9:30 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Sven Wischnowsky @ 1999-02-02  8:04 UTC (permalink / raw)
  To: zsh-workers


Try this:

  % foo=(a b)
  % echo $foo
  a b
  % foo=bar
  % echo $foo
  bar
  % typeset -A foo
  % foo[a]=1
  % foo[b]=2
  % echo $foo
  1 2
  % foo=bar
  % echo $foo
  1 2                   # Oops?
  % echo ${(kv)foo}
  a 1 b 2               # Yes, really.

...or is this the intended behavior? If so, why?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug with associative arrays(?)
  1999-02-02  8:04 Bug with associative arrays(?) Sven Wischnowsky
@ 1999-02-02  8:36 ` Peter Stephenson
  1999-02-02  9:30 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 1999-02-02  8:36 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
>   % typeset -A foo
>   % foo[a]=1
>   % foo[b]=2
>   % echo $foo
>   1 2
>   % foo=bar
>   % echo $foo
>   1 2                   # Oops?

That's the patch of Bart's that keeps getting missed out of my
versions.  It should now look something like this:

--- ../patched/zsh-3.1.5-pws-5/Src/params.c	Wed Jan 13 00:20:25 1999
+++ ./Src/params.c	Sun Jan 24 10:25:10 1999
@@ -1500,7 +1500,7 @@
     } else {
 	if (!(v = getvalue(&s, 1)))
 	    createparam(t, PM_SCALAR);
-	else if (PM_TYPE(v->pm->flags) == PM_ARRAY &&
+	else if ((PM_TYPE(v->pm->flags) & (PM_ARRAY|PM_HASHED)) &&
 		 !(v->pm->flags & (PM_SPECIAL|PM_TIED)) && unset(KSHARRAYS)) {
 	    unsetparam(t);
 	    createparam(t, PM_SCALAR);

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug with associative arrays(?)
  1999-02-02  8:04 Bug with associative arrays(?) Sven Wischnowsky
  1999-02-02  8:36 ` Peter Stephenson
@ 1999-02-02  9:30 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-02-02  9:30 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On Feb 2,  9:04am, Sven Wischnowsky wrote:
} Subject: Bug with associative arrays(?)
}
} Try this:
} 
}   % foo=(a b)
}   % echo $foo
}   a b
}   % foo=bar
}   % echo $foo
}   bar
}   % typeset -A foo
}   % foo[a]=1
}   % foo[b]=2
}   % echo $foo
}   1 2
}   % foo=bar
}   % echo $foo
}   1 2                   # Oops?
}   % echo ${(kv)foo}
}   a 1 b 2               # Yes, really.
} 
} ...or is this the intended behavior? If so, why?

I can't get this to happen to me.  (Cute cut'n'paste trick follows.)

zagzig[66] Src/zsh -f
zagzig% x='  % foo=(a b)
quote>   % echo $foo
quote>   a b
quote>   % foo=bar
quote>   % echo $foo
quote>   bar
quote>   % typeset -A foo
quote>   % foo[a]=1
quote>   % foo[b]=2
quote>   % echo $foo
quote>   1 2
quote>   % foo=bar
quote>   % echo $foo
quote>   1 2                   # Oops?
quote>   % echo ${(kv)foo}
quote>   a 1 b 2               # Yes, really.
quote> '
zagzig% x=("${(@f)x}")
zagzig% print -l ${${(M)x:#??%*}##*%}
 foo=(a b)
 echo $foo
 foo=bar
 echo $foo
 typeset -A foo
 foo[a]=1
 foo[b]=2
 echo $foo
 foo=bar
 echo $foo
 echo ${(kv)foo}
zagzig% eval "$( !! )"
a b
bar
1 2
bar
bar
zagzig% 


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-02-02  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-02  8:04 Bug with associative arrays(?) Sven Wischnowsky
1999-02-02  8:36 ` Peter Stephenson
1999-02-02  9:30 ` Bart Schaefer

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).