Opened 21 years ago
Closed 18 years ago
#96 closed defect (fixed)
Variables out of scope
Reported by: | jlaybar | Owned by: | danirus |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Kernel | Version: | head |
Severity: | normal | Keywords: | |
Cc: | Alfredo Torre |
Description
This code should return global x and y instead of a and b
Matrix a = Row(0,0);
Matrix b = Row(1,1);
Matrix x = Row(2,2,2);
Matrix y = Row(3,3,3);
Matrix fun1( Matrix q, Matrix p)
{
WriteLn( " q:<<q+?"+NL+"p:<<p+?");
WriteLn( "-------------------------------------------------------------");
WriteLn( " TOL SE VUELVE MAJARA Y ASIGNA MAL LAS VARIABLES
GLOBALES"+NL);
WriteLn( "Asignacion Incorrecta: "+NL+"x:<<x+?"+NL+"y:<<y+?");
WriteLn( "-------------------------------------------------------------");
p+q+x+y
};
Set fun2( Matrix p, Matrix q)
{
Matrix fun3( Matrix x, Matrix y)
{
fun1(x,y)
};
Matrix out = fun3(p,q);
WriteLn( "q:<<q+?"+NL+"p:<<p+?");
WriteLn( "Asignacion Correcta:"+NL+"x:<<x+?"+NL+"y:<<y+?");
};
Set salida = fun2(a,b);
Change History (10)
comment:1 Changed 21 years ago by
Status: | new → assigned |
---|
comment:2 Changed 21 years ago by
comment:3 Changed 21 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I have just committed some changes in the core of Tol to give a solution for
this bug.
If you are trying to resolve the value of variable "salida", executing while
reading the code above this messages, practically is ovious that the value
returned must be "2" but not "1".
Implementation Info:
BUserFunction has a new attribute called fInsideLevel_ that stores the level_
used inside a BUsedFunction. When Tol evaluates function's code, all variables
needed are searched into the stack_, but only those with a level_ <= to
fInsideLevel_ are accesible to the function.
comment:4 Changed 21 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Now appears another problem related with the Scope of variables with the same
fInsideLevel_. A better solution needs a reimplementation of the common stack_
that implements local scopes.
Code has been returned back to previous state in CVS, until we have a definitive
solution. The intermediate solution is also there, not erased.
Daniel
comment:5 Changed 21 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
This bug should be already clossed.
The solution was implemented, but someone of us forgot to close it.
comment:6 Changed 21 years ago by
Cc: | Alfredo Torre added |
---|
comment:8 Changed 18 years ago by
bug_file_loc: | → http://cvs.tol-project.org/viewcvs.cgi/tol_tests/tol/Bugzilla/bug_000096 |
---|
comment:9 Changed 18 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Problem happens again almost a year ago
I cannot find any version of TOL where this problem is fixed.
comment:10 Changed 18 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
It has been a confussion because now scope is DYNAMIC and this is not an error
We can follow the same problem with this short code:
Real fun1(Real p1) { x };
Real fun2(Real p2)
{
};
Real a = 1;
Real x = 2;
Real salida = fun2(a);
Variable salida must be "2" the value of global variable "x", but actually
returns "1" the value of "p2" (assigned to "x" parameter of fun3 in its stack).