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

Fatal error: Bad machine state #736

Closed
rybern opened this issue Oct 8, 2022 · 3 comments
Closed

Fatal error: Bad machine state #736

rybern opened this issue Oct 8, 2022 · 3 comments
Labels
Bug The observed behaviour is incorrect or unexpected.

Comments

@rybern
Copy link

rybern commented Oct 8, 2022

Describe the bug
See screenshot

To Reproduce
Here's my script file: https://gist.github.com/rybern/4f42f178ae3b987613eabf2290d1b8d3

You can see the last command I ran; I don't know what other context is relevant

Expected behavior
The bot should keep farming :)

It seems to halt at the second iteration of farm2Next

Screenshots
2022-10-07-223413_3840x2160_scrot

Additional context
By the way I am loving this game!

@rybern rybern added the Bug The observed behaviour is incorrect or unexpected. label Oct 8, 2022
@byorgey
Copy link
Member

byorgey commented Oct 8, 2022

Thanks for the report, and glad you're enjoying the game! Just a quick guess, this is probably #681. But I'll take a closer look tomorrow.

@byorgey
Copy link
Member

byorgey commented Oct 8, 2022

After looking into this a bit more, I'm now quite certain this is an instance of #681. The binding of b in the definition of sharv (i.e. b <- ishere i) leaks out into the definition of pick and from there into pickerBot; the times function also uses the name b, and at some point one of them erroneously overrides the other, so we end up with true (the value of b from sharv) being applied to an argument (which is how b is used in the definition of times).

As a workaround, you could try renaming one of the occurrences of b.

But I really need to fix #681, it is a kind of embarrassing bug. 😳

@rybern
Copy link
Author

rybern commented Oct 8, 2022

Successful workaround, thanks! I'll stick to unique local names.

@rybern rybern closed this as completed Oct 8, 2022
mergify bot pushed a commit that referenced this issue Jun 19, 2024
…tate (#1928)

The big idea of this PR is to add a new type of CESK machine state, `Suspended`, which is a state the base robot automatically goes into after completing execution of a program entered at the REPL.  It is as if the base robot is still within the local context of any definitions etc. entered previously, just printed out an "intermediate result", and is now waiting to find out what the next term to be executed will be.  This allows us to treat `def` as syntax sugar for `let` and results in a much cleaner way to manage the context of definitions, which in turn allows us to remove a whole lot of special cases and fixes several annoying bugs.  See #1087 for more explanation and discussion.

Things that are **deleted** (!) by this PR:
- `TDef` (`def` is now just syntax sugar for `let`) (#997)
- `VResult` (we no longer need to return anything other than plain values)
- `FUnionEnv`, `FDiscardEnv`, `FLoadEnv` (we no longer need machinery to collect up definitions while evaluating terms)
- `ProcessedTerm` (just a plain `TSyntax` (i.e. `Syntax' Polytype`) is now enough)
- `Module` (it only existed to package up some contexts with typechecked terms, but we don't need them anymore)
- `RobotContext` and `topContext` (we don't need to store those things separately any more, they are just stored in the `CESK` machine where they belong)

Additions/changes:
- The `Requirement` module is split into `Requirements.Type` and `Requirements.Analysis` to avoid circular module imports
- New `Suspended` state for the CESK machine
- `def` and `tydef` are now allowed anywhere (even nested inside other definitions etc.) since `def x = y end; z` is just syntax sugar for `let x = y in z` (see #349)
- Code size decreased slightly for many programs using `def`, since `def` is now a synonym for `let`, and consecutive `def`s therefore do not require a `bind`.

Closes #1087.  Fixes #681 (hence also #736, #1796). Fixes #1032. Closes #1047. Closes #997. Fixes #1900. Fixes #1466. Fixes #1424.

See also #636.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug The observed behaviour is incorrect or unexpected.
Projects
None yet
Development

No branches or pull requests

2 participants