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 when using itN resulting from a bind #977

Closed
byorgey opened this issue Jan 7, 2023 · 3 comments · Fixed by #978
Closed

Fatal error when using itN resulting from a bind #977

byorgey opened this issue Jan 7, 2023 · 3 comments · Fixed by #978
Labels
Bug The observed behaviour is incorrect or unexpected. C-Low Hanging Fruit Ideal issue for new contributors. G-CESK machine This issue has to do with the CESK machine (the Swarm language interpreter). G-REPL An issue having to do with the REPL. S-Moderate The fix or feature would substantially improve user experience.

Comments

@byorgey
Copy link
Member

byorgey commented Jan 7, 2023

Describe the bug
Sometimes, using one of the auto-generated itN variables can trigger a fatal "bad application of execConst" error, because the itN contains a VResult which the execConst code is not expecting to see.

To Reproduce

  • Start a creative game.
  • create "tree"
  • def mk = r <- build {}; return r end
  • mk
  • give it0 "tree"

Expected behavior
This ought to work. Probably we just need to strip VResult before storing the value of an itN variable.

Screenshots
itN-fatal

@byorgey byorgey added Bug The observed behaviour is incorrect or unexpected. C-Low Hanging Fruit Ideal issue for new contributors. S-Moderate The fix or feature would substantially improve user experience. G-CESK machine This issue has to do with the CESK machine (the Swarm language interpreter). G-REPL An issue having to do with the REPL. labels Jan 7, 2023
byorgey added a commit that referenced this issue Jan 7, 2023
@byorgey
Copy link
Member Author

byorgey commented Jan 7, 2023

I have a PR with a fix (#978), but overall I'm not happy with the way we handle VResult. It is a fertile source of bugs (#977 , #858, #327, #328) and will probably continue to be so because of some subtle invariants. It's necessary internally in order to pass along intermediate results that also carry an environment of bound names, but there are also many places where we don't expect to see it and don't want to have to worry about dealing with it. A few options for improving the situation that come to mind:

  1. Remove VResult from Value, and create a wrapper type for "values with environment" (EValue?) which can be either a Value or a VResult, and carefully decide which instances of the Value type should change to EValue.
  2. Add a type parameter to Value that indicates whether it is allowed to contain VResult or not.
  3. Get rid of VResult somehow??
  4. Something else???

@xsebek
Copy link
Member

xsebek commented Jan 8, 2023

@byorgey I like option 1) because it will force us to use the values correctly in all places.

@byorgey
Copy link
Member Author

byorgey commented Jan 8, 2023

@xsebek What I had in mind for option 2) should do that as well, though I guess I did not explain it well. I had in mind a GADT where the type parameter actually enforced whether there could be VResult, and then we have to choose which type parameter to use where, just like with option 1) we have to choose which type to use where. However, option 1) definitely has simplicity going for it.

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. C-Low Hanging Fruit Ideal issue for new contributors. G-CESK machine This issue has to do with the CESK machine (the Swarm language interpreter). G-REPL An issue having to do with the REPL. S-Moderate The fix or feature would substantially improve user experience.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants