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:
parent
c9ab2bf594
commit
dcb000e53a
1 changed files with 13 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue