#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
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
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
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:11 Changed 11 years ago by
(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:14 Changed 11 years ago by
(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
Quizá está relacionado con comportamientos como estos:
x
: