You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because f is static, Corrode defers translating it until it encounters the call from g. Because the translation was deferred, right now, it runs in the scope where the first call was encountered. That means that when it translates the assignment x = 1, Corrode believes that the type of x is char *, not int as it should be. The result is that f translates this way:
unsafeexternfnf(){
x = 1i32as(*mutu8);}
Which is, of course, complete nonsense, and the Rust compiler sensibly reports "mismatched types" on the assignment. (This example also triggers issue #92 but this problem should be solved independently of that one.)
One way to solve this would be:
get the EnvState value at the beginning of interpretFunction, so we have a reference to the right environment to use later.
Inside the block that begins with mapExceptT (local setRetTy) $ scope $ do, reset the EnvState to the saved version. But this is a little tricky, because we must not reset the GlobalState that's inside the EnvState. So something like this should work:
lift (modify (\ current -> old { globalState = globalState current }))
Another way to solve this would do pretty much exactly the same thing, except you'd do it in runOnce instead of in interpretFunction, so that all deferred computations would be guaranteed to run in the environment as it stood at the time they were deferred. That's probably better.
The text was updated successfully, but these errors were encountered:
Consider this program:
Because
f
isstatic
, Corrode defers translating it until it encounters the call fromg
. Because the translation was deferred, right now, it runs in the scope where the first call was encountered. That means that when it translates the assignmentx = 1
, Corrode believes that the type ofx
ischar *
, notint
as it should be. The result is thatf
translates this way:Which is, of course, complete nonsense, and the Rust compiler sensibly reports "mismatched types" on the assignment. (This example also triggers issue #92 but this problem should be solved independently of that one.)
One way to solve this would be:
get
theEnvState
value at the beginning ofinterpretFunction
, so we have a reference to the right environment to use later.mapExceptT (local setRetTy) $ scope $ do
, reset theEnvState
to the saved version. But this is a little tricky, because we must not reset theGlobalState
that's inside theEnvState
. So something like this should work:Another way to solve this would do pretty much exactly the same thing, except you'd do it in
runOnce
instead of ininterpretFunction
, so that all deferred computations would be guaranteed to run in the environment as it stood at the time they were deferred. That's probably better.The text was updated successfully, but these errors were encountered: