Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#11 Errors with compound variables

closed
Mark Hessling
None
5
2002-02-26
2002-01-20
Mark Hessling
No

Submitted by Mark Wooding:
There's a bug in expose_compound. As far as I can
tell, it's always
been there.

The problem is when expose_compound reuses `tptr' to
find the leaf of
the old stem it needs to expose in the new proclevel.
If it finds it's
not there, it's lost track of where the stem was, and
takes a wild guess
that it's at the front of the hash chain in the
previous proclevel.
This is often right. However, there are two
circumstances when it
isn't:

* if the entire stem was exposed by an intervening
procedure, it'll
find a stem with a `realbox' pointer but no index
table [bug1.rexx];
and

* if there's a non-stem thing earlier in the hash
chain, it'll find
that, and it won't have an index table [bug2.rexx].

Strange things can occur if the function actually
finds another stem
variable by mistake [bug3.rexx].

The fix is easy: remember where the stem really is. I
attach unified
diffs for the released 2.2 version and for 3.0beta2,
and the three test
cases.
Fix follows against 3.0:

--- buggy-variable.c Sat Jan 19 23:57:57 2002
+++ variable.c Sat Jan 19 23:56:03 2002
@@ -1418,19 +1418,19 @@
tptr = TSD->currlevel->vars[hashv] ;
}

- tptr = tptr->index[hashval2] ;
- for (; tptr && Str_cmp(tptr->name,indexstr);
tptr=tptr->next)
+ tiptr = tptr->index[hashval2] ;
+ for (; tiptr && Str_cmp(tiptr->name,indexstr);
tiptr=tiptr->next)
;
- for (; tptr && tptr->realbox; tptr=tptr->realbox )
+ for (; tiptr && tiptr->realbox; tiptr=tiptr-
>realbox )
;
- if (!tptr)
+ if (!tiptr)
{
- newbox(TSD,indexstr,NULL,&TSD->currlevel->vars
[hashv]->index[hashval2])
;
- tptr = TSD->currlevel->vars[hashv]->index
[hashval2] ;
- tptr->stem = TSD->currlevel->vars[hashv] ;
+ newbox(TSD,indexstr,NULL,&tptr->index
[hashval2]) ;
+ tiptr = tptr->index[hashval2] ;
+ tiptr->stem = tptr ;
}

- nptr->realbox = tptr /*TSD->currlevel->vars[hashv]-
>index[hashval2] */;
+ nptr->realbox = tiptr /*TSD->currlevel->vars
[hashv]->index[hashval2] */;
/* FGC: Maybe, we need to set valid? In case of an
error try valid setting
first; already found one error of this
type. */

Test Programs:
bug1.rexx
=========
call first();
say stem.index;
exit;

first: procedure expose stem.;
call second();
return;

second: procedure expose stem.index;
stem.index = "correct";
return;

bug2.rexx

stem. = "bar";
stem = "spong";
call proc();
say stem.index;
exit;

proc: procedure expose stem.index;
stem.index = "correct";
return;

bug3.rexx

ba. = "";
ab.foo = "good";
call proc();
say ab.foo;
exit;

proc: procedure expose ba.foo;
ba.foo = "bad";
return;

Discussion

  • Mark Hessling
    Mark Hessling
    2002-02-26

    • summary: Errors with compund variables --> Errors with compound variables
    • status: open --> closed
     
  • Mark Hessling
    Mark Hessling
    2002-02-26

    Logged In: YES
    user_id=86185

    Fixes applied and available in 3.0 final release

     
  • Mark Hessling
    Mark Hessling
    2002-02-26

    Logged In: YES
    user_id=86185

    Fixes applied and available in 3.0 final release