Skip to content
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

The SAW REPL is not in a useful state after a failure while loading a file #1341

Closed
nano-o opened this issue Jun 15, 2021 · 2 comments · Fixed by #1349
Closed

The SAW REPL is not in a useful state after a failure while loading a file #1341

nano-o opened this issue Jun 15, 2021 · 2 comments · Fixed by #1349
Assignees

Comments

@nano-o
Copy link
Contributor

nano-o commented Jun 15, 2021

In the SAW REPL, let's say I run include "mydir/file.saw" and a proof in the middle of file.saw fails. At that point I get back a prompt in the REPL. However, none of the definitions appearing in file.saw before the line that fails seem available. So, to debug file.saw interactively, I have to comment-out all the lines after and including the failing line, restart the REPL, and include the file again. This can take a lot of time. What would be great is if, upon failure, one would be left with a REPL in the state it was just before interpreting the failing line in file.saw.

Another issue is that the current directory of the REPL process is now changed to mydir.

@brianhuffman
Copy link
Contributor

I've noticed this behavior too, where if there's an error in the middle of loading a file using include at the REPL, all the declarations get rolled back. The reason for this behavior is how the TopLevel monad is implemented: It uses StateT wrapped around IO (basically TopLevel a is TopLevelState -> IO (a, TopLevelState)). Exceptions and errors are implemented by throwing exceptions in IO. The problem is that when an error occurs in an inner monad, we never get the updated TopLevelState value, so the state changes are lost.

Would you rather change the default behavior so that any changes to the TopLevel state (including top-level saw-script declarations) are preserved up to the point where an error happens? If so, then we should probably reimplement the TopLevel monad so that we can preserve the state updates when errors occur. Probably the easiest way to do this would be to use something like IORef TopLevelState -> IO a instead of TopLevelState -> IO (a, TopLevelState).

@nano-o
Copy link
Contributor Author

nano-o commented Jun 16, 2021

Would you rather change the default behavior so that any changes to the TopLevel state (including top-level saw-script declarations) are preserved up to the point where an error happens?

Yes, that's what I had in mind.

@brianhuffman brianhuffman self-assigned this Jun 21, 2021
brianhuffman pushed a commit that referenced this issue Jun 22, 2021
Also reimplement the `REPL` monad to adapt to this change. This
makes it so that the `REPL` monad can also preserve state changes
when an exception is thrown in a `TopLevel` action.

Fixes #1341.
brianhuffman pushed a commit that referenced this issue Jun 22, 2021
Also reimplement the `REPL` monad to adapt to this change. This
makes it so that the `REPL` monad can also preserve state changes
when an exception is thrown in a `TopLevel` action.

Fixes #1341.
@brianhuffman brianhuffman linked a pull request Jun 22, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants