-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Definitions loaded via --run
have their memory cells trashed
#333
Comments
Hmm, actually, thinking about it more, I am not quite so sure the above is correct. |
Note we now have what #312 (comment) hinted at, where `--run` works in any scenario, not just classic mode, since we have merged classic and challenge modes into the more generic "scenario" framework. This still suffers from #333, but that bug already existed before, so I'm leaving it to be fixed separately.
Trying to trace the exact code path that happens when we use
|
I logged the exact sequence of CESK machine states that results when we run via the REPL vs via |
Describe the bug
Any
def
s in a file loaded via the--run
command-line argument (#312) will not work since their corresponding memory cell gets thrown away.To Reproduce
test.sw
:swarm --run test.sw
.m
at the REPL.This should generate an error about not having the right devices to move; instead, it generates
fatal error: Reference to unknown memory cell 0
.Additional context
I think I already know why this is happening, but I am filing the issue just to be able to properly track and discuss it. This bug apparently has existed ever since #312 was merged, which I guess was insufficiently tested. It can ultimately be traced back to strangeness with typechecking
run
, and points toward the need to do something like #208 (comment) .When the
--run
flag is used, we callinitMachine
to create a CESK machine that will execute the relevantrun
command. However,initMachine
looks at the type and generated environment of the given term to decide what stack frames the CESK machine should start with. Sincerun(foo)
has typecmd ()
but has an empty environment,initMachine
starts the stack with only anFExec
frame but noFLoadEnv
frame. That means any definitions in the file being run will have the corresponding store thrown away. If the type ofrun
properly took into account the definitions that will be generated when it is executed, this wouldn't be an issue.The text was updated successfully, but these errors were encountered: