ocaml-dune / csexp

Minimal support for Canonical S-expressions
MIT License
27 stars 7 forks source link

Dead code in input_opt #7

Closed rgrinberg closed 3 years ago

rgrinberg commented 4 years ago

Consider the End_of_file catch clause from this snippet:

    | exception End_of_file ->
      if LargeFile.pos_in ic = pos then
        Ok None
      else
        Error premature_end

As far as I can tell, End_of_file can't be raised because read_{char,string} catch it. @jeremiedimino what was the intention of this?

ghost commented 4 years ago

Indeed :facepalm:

The more I think about it, the more I'm thinking we should introduce an API similar to the parsexp one where we feed characters to the parser. At least, it becomes up to the caller to deal with IO errors and everything becomes more explicit.

ghost commented 4 years ago

Fixed by #9