Skip to content

Commit 3d19b93

Browse files
committed
Fix bug in ImperativeIO.getInstream
Properly flush the "imperative" ImperativeIO buffer when realizing the underlying stream via `getInstream`. Failing to reset the `first` and `last` refs when realizing the `StreamIO.instream` from an `ImperativeIO.instream` that is in "imperative" mode allows subsequent `ImperativeIO.input*` functions to advance the stream with respect to the "imperative" mode but not advance the `StreamIO.instream`. After realizing the `StreamIO.instream` from an `ImpearativeIO.instream`, the stream should be in "stream" mode and always advance the `StreamIO.instream`. Fixes #535
1 parent e26362e commit 3d19b93

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

basis-library/io/imperative-io.fun

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* Copyright (C) 2013,2017 Matthew Fluet.
1+
(* Copyright (C) 2013,2017,2023 Matthew Fluet.
22
* Copyright (C) 2002-2007 Henry Cejtin, Matthew Fluet, Suresh
33
* Jagannathan, and Stephen Weeks.
44
*
@@ -681,7 +681,7 @@ fun getInstream (ib as In {state, ...}) =
681681
AS.vector (AS.slice (buf, f,
682682
SOME (l - f)))))
683683
else doit (false, NONE)
684-
val () = state := Stream s
684+
val () = setInstream (ib, s)
685685
in
686686
s
687687
end

0 commit comments

Comments
 (0)