diff --git a/Src/builtin.c b/Src/builtin.c index dd28c8b47..ba384068d 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2130,6 +2130,12 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), * ii. we are creating a new local parameter */ if (usepm) { + if (asg->is_array ? + (asg->value.array && !(PM_TYPE(pm->node.flags) & (PM_ARRAY|PM_HASHED))) : + (asg->value.scalar && (PM_TYPE(pm->node.flags & (PM_ARRAY|PM_HASHED))))) { + zerrnam(cname, "%s: inconsistent type for assignment", pname); + return NULL; + } on &= ~PM_LOCAL; if (!on && !roff && !ASG_VALUEP(asg)) { if (OPT_ISSET(ops,'p')) @@ -2203,6 +2209,13 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), return pm; } + if (asg->is_array ? + (asg->value.array && !(on & (PM_ARRAY|PM_HASHED))) : + (asg->value.scalar && (on & (PM_ARRAY|PM_HASHED)))) { + zerrnam(cname, "%s: inconsistent type for assignment", pname); + return NULL; + } + /* * We're here either because we're creating a new parameter, * or we're adding a parameter at a different local level,