From 30e356eb1a599dc634e2b46da272afacd46553de Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Tue, 14 May 2019 12:10:10 +0100
Subject: 44296: "typeset Q= {X}" crashed the shell.
---
ChangeLog | 5 +++++
Src/parse.c | 8 ++++++++
Test/B02typeset.ztst | 7 +++++++
3 files changed, 20 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index da6de05f5..e44e2f08d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-14 Peter Stephenson
+
+ * 44296: Src/parse.c, Test/B02typeset.ztst: "typeset Q= {X}"
+ crashed the shell.
+
2019-05-13 Peter Stephenson
* 44259: Src/signals.c: Ensure we can set signal to default
diff --git a/Src/parse.c b/Src/parse.c
index 22e553a16..27234497b 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1899,6 +1899,14 @@ par_simple(int *cmplx, int nr)
p += nrediradd;
sr += nrediradd;
}
+ else if (postassigns)
+ {
+ /* C.f. normal case below */
+ postassigns++;
+ ecadd(WCB_ASSIGN(WC_ASSIGN_SCALAR, WC_ASSIGN_INC, 0));
+ ecstr(toksave);
+ ecstr(""); /* TBD can possibly optimise out */
+ }
else
{
ecstr(toksave);
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index ac86e0ad1..e7bf93794 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -1101,3 +1101,10 @@
>export zsh_exported_readonly_scalar=1
>readonly zsh_exported_readonly_array=( 2 )
>readonly zsh_exported_readonly_scalar=1
+
+ # The second case was buggy as it needs special handling in postassigns
+ (typeset {X})
+ (typeset Q= {X})
+1:Regression test for {...} parsing in typeset
+?(eval):typeset:2: not valid in this context: {X}
+?(eval):typeset:3: not valid in this context: {X}
--
cgit 1.4.1