submodel reuse not working due to apparent syntax error
When attempting to use the submodel reuse feature, the language complains about syntax error and expected characters. An error message similar to the following is printed:
Syntax error: None:2:19 --> ar1 + var2*@d9c7var2 <--
Expected '(' or '.' or '[' or '**' or '*' or '/' or '+' or '-' or 'for' or 'on' or '\s*(^|;)' or EOF
This error can be reproduced by following these steps:
- Initiate an interactive session with
texts session -w -r
- Add a new variable
var1 = 2
. Verify node has been completed (%hist
magic) - Use the
%uuid
command to get model's identifier (UUID_from_model_1
). - Initiate a new session with a fresh model via the
%new
magic - Create a new variable, for example
var2 = 4
. Verify completion of the node. - Assign to a new variable the sum of
var2
andvar1
(from model_1)suma = var2 + var1@UUID_from_model_1
- The syntax error message is printed.
The problem persists in releases v0.3.0 and v0.3.1.
The error also occurrs when model_1
is executed as script.
Interestingly, it is possible to switch between models without problem via the %uuid UUID_from_model_X
magic.
The error message is printed again when trying to reuse model_2's var2
from within model_1.
Starting the session with the --enable_logging --logging_level DEBUG
flags shows:
Input > suma = var2 + var1@97572c098d324582b1e0d4eac97a1ffa
INFO:virtmat.language.interpreter.session_manager:using variable "var1" from model 97572c098d324582b1e0d4eac97a1ffa <-!
DEBUG:virtmat.language.interpreter.session_manager:extracted lines of code: ['var1 = 2'] <-!
INFO:virtmat.language.interpreter.session_manager:reused variables: {'var1'} <-!
DEBUG:virtmat.language.interpreter.session_manager:local variables: {'var2'}
Syntax error: None:2:19 --> ar2 + var1*@9757var1 <--
Expected '(' or '.' or '[' or '**' or '*' or '/' or '+' or '-' or 'for' or 'on' or '\s*(^|;)' or EOF
Input > %hist
COMPLETED 2024-05-03T15:13:45+02:00 var2 = 4
Input >
Input > print(var1@97572c098d324582b1e0d4eac97a1ffa)
INFO:virtmat.language.interpreter.session_manager:using variable "var1" from model 97572c098d324582b1e0d4eac97a1ffa
DEBUG:virtmat.language.interpreter.session_manager:extracted lines of code: ['var1 = 2']
INFO:virtmat.language.interpreter.session_manager:reused variables: {'var1'}
DEBUG:virtmat.language.interpreter.session_manager:local variables: {'var2'}
Syntax error: None:2:11 --> print(var1*@9757var1 <--
Expected '(' or '.' or '[' or '<=' or '>=' or '>' or '<' or '!=' or '==' or 'if' or '^|;|\)|\,|\=|\<|\>|\[' or KeywordAfterID or '**' or '*' or '/' or '+' or '-' or ',' or ')'
It looks like the variable var1
is tagged for reuse and actually recovered (see lines higlighted with <-!
).
However, there seems to be a problem with the syntax