Skip to content

Commit

Permalink
Fix set_output/1 and set_input/1 not updating the alias
Browse files Browse the repository at this point in the history
Before this change, the following set of queries would behave incorrectly:

```
?- open("/tmp/out.log", write, S), set_output(S).
   prints(""), write("/tmp/out.log", "S = stream(...)").
?- write(user_output, hello).
   prints("hello"), unexpected.
   prints(""), write("/tmp/out.log", "hello"). % Expected, but not found.
```

Now, `set_output/1` and `set_input/1` properly bind the `user_output` and
`user_input` aliases, making the queries above behave as expected.
  • Loading branch information
adri326 committed Feb 6, 2025
1 parent 7f2ce57 commit d8213e2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/machine/system_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5940,6 +5940,7 @@ impl Machine {
}

self.user_input = stream;
self.indices.set_stream(atom!("user_input"), stream);
Ok(())
}

Expand All @@ -5964,6 +5965,7 @@ impl Machine {
}

self.user_output = stream;
self.indices.set_stream(atom!("user_output"), stream);
Ok(())
}

Expand Down

0 comments on commit d8213e2

Please sign in to comment.