pub fn resetparam(pm: &mut param, flags: i32) -> i32Expand description
Port of resetparam(Param pm, int flags) from Src/params.c:3796. C body:
char *s = pm->node.nam;
queue_signals();
if (pm != (Param)(paramtab == realparamtab ?
paramtab->getnode2(paramtab, s) :
paramtab->getnode(paramtab, s))) {
unqueue_signals();
zerr("can't change type of hidden variable: %s", s);
return 1;
}
s = dupstring(s);
unsetparam_pm(pm, 0, 1);
unqueue_signals();
createparam(s, flags);
return 0;Tears pm down + recreates it with flags so the next
assignment lands in a fresh slot of the requested type. Used
by assignsparam when the type-flag of an existing param
changes (e.g. typeset -i x; x="abc" resets x back to scalar).
The paramtab->getnode reachability check at c:3800 catches
the hidden-shadow case (a local var hiding the global pm we
were handed) — without the paramtab vtable we skip the check
and proceed to unset+create.