close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 21 years ago

Closed 21 years ago

Last modified 18 years ago

#146 closed defect (fixed)

General scope error

Reported by: danirus Owned by: danirus
Priority: lowest Milestone:
Component: Various Version: head
Severity: normal Keywords:
Cc:

Description

With next code:
_

Real double(Real a) { a*a };
Real a = 2;
Real b = { double(Real a = 3) };
Real c = 3;

_

Tol shows a message about the duplicity of variable "a". This is an error of
scope, because the third sentence has an inside scope created with OpenToken "{"
and CloseToken "}". The problem is related with a bad use of SEPARATOR Token
into Evaluation Engine (BGrammar::Evaluate).

To resolve Bug 96 (of Jaime López Aybar) this should be resolved first.

To be sure of the importance of SEPARATOR Token, try with this other piece of code:
_

Real double(Real a) { a*a };
Real a = 2;
Real b = { Real x = 1; double(Real a = 3) };
Real c = 3;

_

Now there is no problem. But now, variable "a" takes a wrong value. In "double"
function variable "a" must be the global variable "a" (equal 2).

Change History (3)

comment:1 Changed 21 years ago by danirus

Status: newassigned

comment:2 Changed 21 years ago by danirus

Resolution: fixed
Status: assignedclosed

Resolving bug 146.
This modification resolves a big problem inside the kernel of Tol.
The problem is related with the management of the scope inside a function or
inside local code blocks. This is the previous solution to get an improvement of the
Local Scope Management in Tol.
Now the Local Scope works only with a stack storing all objects created inside each
function called. In a normal situation with more than 5 or 6 functions called at a
time, the time spent looking for an object inside this stack is dramatically high.

comment:3 Changed 18 years ago by Víctor de Buen Remiro

bug_file_loc: http://cvs.tol-project.org/viewcvs.cgi/tol_tests/tol/Bugzilla/bug_000146
Note: See TracTickets for help on using tickets.