@@ -525,18 +525,18 @@ newparamtable(int size, char const *name)
525525
526526/**/
527527static HashNode
528- getparamnode (HashTable ht , const char * nam )
528+ loadparamnode (HashTable ht , Param pm , const char * nam )
529529{
530- HashNode hn = gethashnode2 (ht , nam );
531- Param pm = (Param ) hn ;
532-
533530 if (pm && (pm -> node .flags & PM_AUTOLOAD ) && pm -> u .str ) {
531+ int level = pm -> level ;
534532 char * mn = dupstring (pm -> u .str );
535-
536- (void )ensurefeature (mn , "p:" , (pm -> node .flags & PM_AUTOALL ) ? NULL :
537- nam );
538- hn = gethashnode2 (ht , nam );
539- if (!hn ) {
533+ (void )ensurefeature (mn , "p:" , nam );
534+ pm = (Param )gethashnode2 (ht , nam );
535+ while (pm && pm -> level > level )
536+ pm = pm -> old ;
537+ if (pm && (pm -> level != level || (pm -> node .flags & PM_AUTOLOAD )))
538+ pm = NULL ;
539+ if (!pm ) {
540540 /*
541541 * This used to be a warning, but surely if we allow
542542 * stuff to go ahead with the autoload stub with
@@ -546,7 +546,14 @@ getparamnode(HashTable ht, const char *nam)
546546 nam );
547547 }
548548 }
549+ return (HashNode )pm ;
550+ }
549551
552+ /**/
553+ static HashNode
554+ getparamnode (HashTable ht , const char * nam )
555+ {
556+ HashNode hn = loadparamnode (ht , (Param )gethashnode2 (ht , nam ), nam );
550557 if (hn && ht == realparamtab && !(hn -> flags & PM_UNSET ))
551558 hn = resolve_nameref ((Param )hn , NULL );
552559 return hn ;
@@ -2236,6 +2243,7 @@ fetchvalue(Value v, char **pptr, int bracks, int flags)
22362243 ((pm -> node .flags & PM_UPPER ) ? - (pm -> base ) :
22372244 pm -> base ) : locallevel );
22382245 pm = upscope (p1 , scope );
2246+ pm = (Param )loadparamnode (paramtab , pm , ref );
22392247 }
22402248 if (!(p1 && pm ) ||
22412249 ((pm -> node .flags & PM_UNSET ) &&
@@ -6313,12 +6321,11 @@ resolve_nameref(Param pm, const Asgment stop)
63136321 pm -> base ) : ((Param )hn )-> level );
63146322 hn = (HashNode )upscope ((Param )hn , scope );
63156323 }
6324+ hn = loadparamnode (paramtab , (Param )hn , seek );
63166325 /* user can't tag a nameref, safe for loop detection */
63176326 pm -> node .flags |= PM_TAGGED ;
63186327 }
63196328 if (hn ) {
6320- if (hn -> flags & PM_AUTOLOAD )
6321- hn = getparamnode (realparamtab , seek );
63226329 if (!(hn -> flags & PM_UNSET ))
63236330 hn = resolve_nameref ((Param )hn , stop );
63246331 }
0 commit comments