]> Repositorios git - scryer-prolog.git/commitdiff
clear alias in close before resetting the stream to null (#1231)
authorMark Thom <[email protected]>
Tue, 18 Jan 2022 00:58:09 +0000 (17:58 -0700)
committerMark Thom <[email protected]>
Tue, 18 Jan 2022 00:58:14 +0000 (17:58 -0700)
src/lib/builtins.pl
src/machine/system_calls.rs

index 4619bfad915cbbd2b60da0f5fb17a334916feecc..a060a69c016d807426400ce404813a5fd0209eff 100644 (file)
@@ -1468,7 +1468,8 @@ open(SourceSink, Mode, Stream, StreamOptions) :-
                 atom(SourceSink) ->
                 atom_chars(SourceSink, SourceSinkString)
            ;    SourceSink = SourceSinkString
-           ), '$open'(SourceSinkString, Mode, Stream, Alias, EOFAction, Reposition, Type)
+           ),
+           '$open'(SourceSinkString, Mode, Stream, Alias, EOFAction, Reposition, Type)
        )
     ).
 
index 98130bc2ae2470aaad8a8fd3519899ccd22816fe..c9d988f9294e6e129f1960c40ccc9328a5d1c45d 100644 (file)
@@ -2728,12 +2728,12 @@ impl Machine {
         }
 
         if !stream.is_stdin() && !stream.is_stdout() && !stream.is_stderr() {
-            let close_result = stream.close();
-
             if let Some(alias) = stream.options().get_alias() {
                 self.indices.stream_aliases.remove(&alias);
             }
 
+            let close_result = stream.close();
+
             if let Err(_) = close_result {
                 let stub = functor_stub(atom!("close"), 1);
                 let addr = stream_as_cell!(stream);