Skip to content

Commit

Permalink
Correctly close open channel
Browse files Browse the repository at this point in the history
Co-authored-by: Kesha Hietala <[email protected]>
  • Loading branch information
k4rtik and khieta committed Jul 11, 2022
1 parent a08e910 commit 28a2542
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/openQASM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ let parse_with_error lexbuf =

(* core parsing routine *)
let get_ast f =
let ic = open_in f in
let lexbuf = Lexing.from_channel ic in
close_in ic;
parse_with_error lexbuf
let ch = open_in_bin f in
Fun.protect ~finally: (fun () -> close_in ch) begin fun () ->
let lexbuf = Lexing.from_channel ch in
parse_with_error lexbuf
end

module AST = AST

0 comments on commit 28a2542

Please sign in to comment.