-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Buffer.add_channel discards data #7136
Copy link
Copy link
Closed
Description
Original bug ID: 7136
Reporter: @yallop
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-09-24T15:31:48Z)
Resolution: duplicate
Priority: normal
Severity: minor
Fixed in version: 4.03.0+dev / +beta1
Category: standard library
Duplicate of: #6719
Bug description
The documentation for Buffer.add_channel says:
Raise [End_of_file] if the channel contains fewer than [n]
characters. In this case, the characters are still added to
the buffer, so as to avoid loss of data.
However, when End_of_file is raised the characters are not added to the buffer:
$ cat abc.txt
abc
$ ocaml
OCaml version 4.02.3
let buf = Buffer.create 10;;
val buf : Buffer.t =
Buffer.add_channel buf (open_in "abc.txt") 10;;
Exception: End_of_file.
Buffer.contents buf;;
- : string = ""
Reactions are currently unavailable