]> Repositorios git - scryer-prolog.git/commitdiff
Fix set_output/1 and set_input/1 not updating the alias
authorEmilie Burgun <[email protected]>
Thu, 6 Feb 2025 21:55:40 +0000 (22:55 +0100)
committerEmilie Burgun <[email protected]>
Thu, 6 Feb 2025 22:01:38 +0000 (23:01 +0100)
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.

src/machine/system_calls.rs

index 50c28549fec49d43e5c32fdcfd92366bdae18897..71e9018228851c04a076611eb3d76a16ca267515 100644 (file)
@@ -5940,6 +5940,7 @@ impl Machine {
         }
 
         self.user_input = stream;
+        self.indices.set_stream(atom!("user_input"), stream);
         Ok(())
     }
 
@@ -5964,6 +5965,7 @@ impl Machine {
         }
 
         self.user_output = stream;
+        self.indices.set_stream(atom!("user_output"), stream);
         Ok(())
     }