Open angeloocana opened 2 months ago
get_initial_board
gets passed as the argument board
and then cloned inside get_possible_moves
.
This is one of the cases where the heuristic for finding the problematic cases is too strict. This function has some duplications inside it, but not in its normalized form.
The function desugars to Map/set(Map/set(Map/set(Map/empty, 0, black), 1, white), 2, empty)
, and Map/set
duplicates the key (0, 1 and 2 in this example). However, after normalizing, get_initial_board
reduces to just an ADT value and not a function so the duplications are not a problem.
Unfortunately this check happens directly at runtime with no way of disabling it for your specific function. Ideally we'd have a type system that can assertain whether or not a value will have problematic duplications, but that's not planned for the immediate future.
For now, you can circumvent this issue by applying a dummy value to the function that forces its evaluation:
def get_initial_board(dummy):
return { 0: black, 1: white, 2: empty }
...
def main():
board = get_initial_board(*)
Reproducing the behavior
I'm getting the error
ERROR: attempt to clone a non-affine global reference.
when I call a function to create a Map or List and then pass it to another function. Example:bend run test.bend -s
gives this error:bend run-c test.bend -s
works fine:System Settings
Example:
Additional context
No response