summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c15
-rw-r--r--Src/params.c3
2 files changed, 10 insertions, 8 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 6f98990f9..829b899f8 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2030,11 +2030,10 @@ typeset_single(char *cname, char *pname, Param pm, int func,
int usepm, tc, keeplocal = 0, newspecial = NS_NONE, readonly, dont_set = 0;
char *subscript;
- if (pm && (pm->node.flags & PM_NAMEREF) && !((off|on) & PM_NAMEREF)) {
- if (!(off & PM_NAMEREF)) {
- if ((pm = (Param)resolve_nameref(pm, NULL)))
- pname = pm->node.nam;
- }
+ if (pm && (pm->node.flags & PM_NAMEREF) && !((off|on) & PM_NAMEREF) &&
+ (pm->level == locallevel || !(on & PM_LOCAL))) {
+ if ((pm = (Param)resolve_nameref(pm, NULL)))
+ pname = pm->node.nam;
if (pm && (pm->node.flags & PM_NAMEREF) &&
(on & ~(PM_NAMEREF|PM_LOCAL|PM_READONLY))) {
/* Changing type of PM_SPECIAL|PM_AUTOLOAD is a fatal error. *
@@ -3125,8 +3124,10 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
oldpm->u.str)
asg->value.scalar = dupstring(oldpm->u.str);
/* Defer read-only error to typeset_single() */
- if (!(hn->flags & PM_READONLY))
+ if (!(hn->flags & PM_READONLY)) {
unsetparam_pm(oldpm, 0, 1);
+ hn = NULL;
+ }
}
/* Passing a NULL pm to typeset_single() makes the
* nameref read-only before assignment, which breaks
@@ -3134,7 +3135,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
* so this is special-cased to permit that action
* like assign-at-create for other parameter types.
*/
- if (!(hn->flags & PM_READONLY))
+ if (hn && !(hn->flags & PM_READONLY))
hn = NULL;
}
}
diff --git a/Src/params.c b/Src/params.c
index 4bcf41c22..973df3fe5 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1034,7 +1034,8 @@ createparam(char *name, int flags)
}
if (oldpm && !(flags & PM_NAMEREF) &&
- (!(oldpm->node.flags & PM_RO_BY_DESIGN) || !(flags & PM_LOCAL)) &&
+ (oldpm->level == locallevel ?
+ !(oldpm->node.flags & PM_RO_BY_DESIGN) : !(flags & PM_LOCAL)) &&
(oldpm->node.flags & PM_NAMEREF) &&
(oldpm = upscope(oldpm, oldpm->base))) {
Param lastpm;