From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13720 invoked from network); 12 Jan 1999 17:59:06 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Jan 1999 17:59:06 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id MAA06174; Tue, 12 Jan 1999 12:56:35 -0500 (EST) Resent-Date: Tue, 12 Jan 1999 12:56:35 -0500 (EST) From: "Bart Schaefer" Message-Id: <990112095552.ZM12994@candle.brasslantern.com> Date: Tue, 12 Jan 1999 09:55:52 -0800 X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@math.gatech.edu Subject: PATCH: 3.1.5-pws-4: minor setaparam() fixup for assoc. arrays MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"G0f1t1.0.PW1.Jpucs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4893 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Consider the following: zsh% typeset -A assoc zsh% : ${(A)assoc[key]::=x y z} This actually "worked" fine and set $assoc[key] to be the array (x y z). However, none of the other substitution code is ready to have associative arrays contain anything but scalars. The following patch turns the above fragment into an error case, and improves the error message in the case of zsh% : ${(AA)=assoc[key]::=x y z} I had mentioned before that perhaps that case should be changed to not produce an error, but upon reflection I think it's better as it is. To assign to a single field of an associative array using the ${...:=...} syntax, simply write zsh% : ${assoc[key]::=value} which already works with the obvious meaning (no change in this patch). Index: Src/params.c =================================================================== --- params.c 1999/01/11 02:19:45 1.20 +++ params.c 1999/01/12 16:51:55 @@ -1534,6 +1534,12 @@ if (!(v = getvalue(&s, 1))) createparam(t, PM_ARRAY); *ss = '['; + if (PM_TYPE(v->pm->flags) == PM_HASHED) { + zerr("attempt to set slice of associative array", NULL, 0); + freearray(val); + errflag = 1; + return NULL; + } v = NULL; } else { if (!(v = getvalue(&s, 1))) @@ -1571,7 +1577,7 @@ } if (strchr(s, '[')) { freearray(val); - zerr("attempt to set slice of associative array", NULL, 0); + zerr("nested associative arrays not yet supported", NULL, 0); errflag = 1; return NULL; } else { -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com