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 12 years ago

Closed 12 years ago

Last modified 9 years ago

#1659 closed defect (fixed)

Error extraño usando PutName

Reported by: Pedro Gea Owned by: Víctor de Buen Remiro
Priority: highest Milestone: Mantainance
Component: Kernel Version: 3.1
Severity: critical Keywords:
Cc:

Description

Localizando un error un tanto dificil de comprender llego a aislar el siguiente código:

Real MyAppend(Set set, Anything data) {
  Set set := [[ data ]];
1};

NameBlock variable = [[
  Set box = Copy(Empty)
]];

Real MyAppend(variable::box, Matrix Rand(1,1,1,1));

Set content = [[
  variable::box[1]
]];

Real {
  Real data = 1;
  WriteLn("Existe 'data' y es de tipo "<<Grammar(data));
  Anything PutName("E", content[1]);
  WriteLn("Existe 'data' y es de tipo "<<Grammar(data));
1};

que devuelve:

Existe 'data' y es de tipo Real
Existe 'data' y es de tipo Matrix

Parece como si PutName liberara un nombre del objeto, anteponiéndose éste incluso a alguno declarado localmente.

Por ejemplo esto:

Set box = Copy(Empty);
Real MyAppend(box, Real 2);
Real {
  Real data = 1;
  Anything PutName("E", box[1]);
  data + 1
}; 

devuelve 3.

Change History (17)

comment:1 Changed 12 years ago by Pedro Gea

Quizá está relacionado con comportamientos como estos:

  • La variable local 'a' sigue pudiéndose referenciar después de cambiarle el nombre:
    Real x = {
      Real a = 1;
      Real PutName("w", a);
      a
    };
    
  • Esto no puede hacerse si 'a' fuera global:
    Real a = 1;
    Real x = {
      Real PutName("w", a);
      a
    };
    
    devuelve:
    ERROR: [] a no es un objeto valido para el tipo Real.
    ERROR: [] x no se pudo crear.
    
  • Aún más puede declararse una vez más, pero al referirnos a ella es la anterior:
    Real x = {
      Real a = 1;
      Real PutName("w", a);
      Real a = 2;
      a
    }; // -> 1
    
  • Y esto ni siquiera devuelve un real para construir x:
    Real x = {
      Real a = 1;
      Real PutName("w", a);
      Real a = 2
    };
    

comment:2 Changed 12 years ago by Víctor de Buen Remiro

(In [5693]) Refs #1659
Now PutName will be executed in a local scope to avoid strange secondary effects

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

Hola Pedro

Cuando quieras puedes probar a compilar tol 3.2 a ver si este apaño te sirve.
Si no da problemas en unos días podemos extender el cambio a tol 3.1

comment:4 Changed 12 years ago by Pedro Gea

Resumo los comportamientos de los siguientes casos:

Caso 1

Set box = Copy(Empty);
Real MyAppend(box, Real 2);
Real {
  Real data = 1;
  Anything PutName("E", box[1]);
  data + 1
}; // =>

Caso 2

Real x = {
  Real a = 1;
  Real PutName("w", a);
  Real a = 2;
  a
}; // =>

usando PutName tal cual y PutName encerrado entre llaves {}.

Caso 1 Caso 1 (usando {}) Caso 2 Caso 2 (usando {})
tolbase_3.1 3 2 1 2
nuevo tolbase_3.2 3 2 2 2

Como vemos, se está solucionando el caso 2 pero no el caso 1.

comment:5 Changed 12 years ago by Víctor de Buen Remiro

(In [5711]) Refs #1659

comment:6 Changed 12 years ago by Víctor de Buen Remiro

Resolution: fixed
Status: newclosed

(In [5713]) Fixes #1659

comment:7 Changed 11 years ago by Víctor de Buen Remiro

(In [5964]) Refs #1659

comment:8 Changed 11 years ago by Víctor de Buen Remiro

(In [5967]) Refs #1708
Refs #1659

comment:9 Changed 11 years ago by Víctor de Buen Remiro

(In [5968]) Refs #1708
Refs #1659

comment:10 Changed 11 years ago by Víctor de Buen Remiro

(In [5969]) Refs #1708
Refs #1659

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

(In [5972]) New release VERSION_BUILD "b019"
Fixes #1708
Fixes #1659

BStackManager has been rewritten using google hash
BUserFunction::Evaluator doesn't clears local names of arguments because there are new instances that will be removed from stack
Argument from_UF of BGrammar::EvaluateTree must be set to true just when called from BUserFunction::Evaluator to avoid to clean the stack too soon
PutName doesn't call to BGrammar::DelObject nor BGrammar::AddObject, it just changes the name and the local or global hash by means of a new method BGrammar::ChangeName

comment:12 Changed 11 years ago by Víctor de Buen Remiro

(In [5973]) Refs #1708
Refs #1659

comment:13 Changed 11 years ago by Víctor de Buen Remiro

(In [5975]) Refs #1708
Refs #1659

comment:14 Changed 11 years ago by Víctor de Buen Remiro

(In [5976]) Fixes #1708
Refs #1659

Last changes related to PutName are incompatible with some abusive uses of this function in some packages as GuiTools or MMS.
The StackManager can use the google hash instead of old n-ary tree, but symbols are not removed from hash table and can be used with the old name after a call to PutName in a local scope.
The rest of changes out of StackManager has been reverted

comment:15 Changed 11 years ago by Jorge

(In [5991]) refs #1708, #1659, volvemos a usar PutName

comment:16 Changed 11 years ago by Jorge

(In [5992]) refs #1659, en ámbito local al cambiar el nombre de un objeto todavía puede referenciarse por el nombre original, eso se ha dejado así por compatibilidad.

comment:17 Changed 9 years ago by Pedro Gea

(In [6818]) Refs #1659
Se elimina un chequeo que no funciona cuando es comprobado en un ámbito local y por tanto no puede ser comprobada por el tester.

Note: See TracTickets for help on using tickets.