1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-16 10:01:16 +01:00

Add errors for incorrect types of assignment

This commit is contained in:
Peter Stephenson 2015-06-22 10:16:52 +01:00
parent c9ab2bf594
commit dcb000e53a

View file

@ -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,