Error reading result from hvm
Describe the bug
One of the subroutines for a simple SAT-Solver that I am trying to develop using Bend is giving me problems, as on execution an error occurs. Not sure if this is a problem with Bend or with HVM, or something that I did wrong.
If I run the program using "bend run", the following error message is shown:
Errors:
Error reading result from hvm. Output :
ERROR: attempt to clone a non-affine global reference.
To me this error message is rather cryptic, but it seems to be a problem that is triggered in HVM.
If I run the program with "bend run-c", the following is shown:
Errors:
Error reading result from hvm. Output :
Result: �
- ITRS: 156
- TIME: 0.00s
- MIPS: 0.19
To Reproduce
I attached both my source code (minimal example) and the generated hvm code (using gen-hvm parameter) to this issue (as txt) sat_minimal.bend.txt sat_minimal.hvm.txt
Desktop:
- OS: Fedora Linux 40
- CPU: Ryzen 9 5900X (x86_64)
- bend-lang 0.2.7
You're not allowed to clone/duplicate high-order functions that themselves duplicate some variables. There are some situations where this could lead to unsound results and so we went with a blanket ban on that for now.
In your program both filter and map do this. For now you have to specialize them for the specific mapping/filtering you want to do
We're still working on the best way to do these checks and present them to the user, sorry if right now it's a bit confusing
Thank you for your replies. They have been helpful. Do not worry, I understand that everything is work-in-progress, and I am sure you will eventually find good solutions for these minor problems.
As a follow up: I changed the implementation, and now I am getting a segmentation fault, but only when running "bend run-c". With "bend run" it runs fine. I opened up another issue (as I do not think they are related) here: https://github.com/HigherOrderCO/Bend/issues/397.
Hey @developedby! What do you mean by:
For now you have to specialize them for the specific mapping/filtering you want to do
Sorry if this is a dumb question, I'm new to bend and I'm having fun but I'm struggling a lot =/
I'm getting the same error ERROR: attempt to clone a non-affine global reference. in my code. I created this small example below reproducing the same issue. How can I fix it? Could you provide some examples or links to where I could learn more about these cloning issues?
empty = 0
white = 1
black = 2
def get_initial_board():
return { 0: black, 1: white, 2: empty }
def get_empty_positions(board):
# We don't even need to use the board variable, just passing it to this function raises the error
return [2]
def get_possible_moves(board, pieces):
fold pieces with pieces_with_possible_moves = []:
case List/Cons:
return pieces.tail(List/Cons((pieces.head, get_empty_positions(board)), pieces_with_possible_moves))
case List/Nil:
return pieces_with_possible_moves
def main():
board = get_initial_board() # If I call any function to create the board I get the error
# board = { 0: black, 1: white, 2: empty } # If I create the board here it works
pieces = [0]
possible_moves = get_possible_moves(board, pieces)
return possible_moves
bend run test.bend -s gives this error:
ERROR: attempt to clone a non-affine global reference.
Errors:
Failed to parse result from HVM.
bend run-c test.bend -s works fine:
Result: [1]
- ITRS: 422
- TIME: 0.00s
- MIPS: 0.38