From d649bf78dc3096d6ca0c705257a928b1acce3b82 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sun, 27 Dec 2020 14:36:35 -0800 Subject: Fix ${(t)var} output, add comparative test cases --- Src/subst.c | 3 ++- Test/E01options.ztst | 15 +++++++++++++++ Test/E03posix.ztst | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Src/subst.c b/Src/subst.c index 96e0914eb..9928be0e9 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2563,7 +2563,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, * Handle the (t) flag: value now becomes the type * information for the parameter. */ - if (v && v->pm && !(v->pm->node.flags & PM_UNSET)) { + if (v && v->pm && ((v->pm->node.flags & PM_DECLARED) || + !(v->pm->node.flags & PM_UNSET))) { int f = v->pm->node.flags; switch (PM_TYPE(f)) { diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 415f46cd7..72749e6ab 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -1451,3 +1451,18 @@ F:If this test fails at the first unsetopt, refer to P01privileged.ztst. 0q:RM_STAR_SILENT *>zsh: sure you want to delete all 15 files in ${PWD:h}/options.tmp \[yn\]\? ${BEL}(|n) *>zsh: sure you want to delete (all <->|more than <->) files in / \[yn\]\? ${BEL}(|n) + + () { + local var + print ${(t)var} + } +0:(t) returns correct type +>scalar-local + + () { + readonly var + typeset -p var + } +0:readonly with typeset -p +F:compare E03posix.ztst +>typeset -r var='' diff --git a/Test/E03posix.ztst b/Test/E03posix.ztst index 5e6eddeba..c59ca4f6e 100644 --- a/Test/E03posix.ztst +++ b/Test/E03posix.ztst @@ -103,3 +103,17 @@ >arg1 arg2 >noktarg1 >0 0 + + () { + local var + print ${(t)var} + } +0:(t) returns correct type +>scalar-local + + () { + readonly var + typeset -p var + } +0:readonly with typeset -p +>typeset -g -r var -- cgit 1.4.1