Open jamesjuett opened 2 years ago
I have not been able to locate the bug, but I have found the cause of the bug.
In class Observable
in observe.ts
, it has a member variable called universalObservers
. When we first click Simulate
button, Lobster does create a runtime function call object and the temporary return variable and send
the message to the observer.
However, in sendMessageToObservers
, when allocateTemporaryObject
in Memory.ts
sends the message to observer, the universalObservers
is empty, which means that message is sent to nowhere. But once we click Restart
, the TemporaryObjectOberserver
shows up all of a sudden, so the message of allocation of temporary object can be received correctly. I have trouble in figuring out where does that observer come from.
Ok, now I find the issue.
In the ctor of SimpleExerciseLobsterOutlet
, it calls stepForward
before the sim
is set. So, none of listeners is attached. So there is no observes when the message of allocation of temporary object is sent to observers.
The solution is to switch the order of the while loop and setSimulation
.
Upon clicking "simulate", the temporary object for the return from
foo()
does not appear, even after stepping forward. However, if the "restart" button is clicked, it will appear.