Skip to content

Commit

Permalink
Validate top-module input
Browse files Browse the repository at this point in the history
Signed-off-by: Rafal Gwozdzinski <rafal.gwozdzinski@gmail.com>
  • Loading branch information
3Rafal committed Jun 18, 2023
1 parent 3f350f9 commit ee987ca
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/ocaml/top.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ module Module = struct
let ctx = Super_context.context sctx in
let src = Path.Build.append_source ctx.build_dir mod_ in
let dir = Path.Build.parent_exn src in
let filename = Path.Build.basename src in
if Sys.file_exists filename then ()
else User_error.raise [ Pp.text "file doesn't exist" ] ;
if Filename.extension filename = ".ml" then ()
else User_error.raise [ Pp.text "file should have '.ml' extension" ] ;
let open Memo.O in
let module_name =
let name = src |> Path.Build.basename |> Filename.chop_extension in
Expand Down

0 comments on commit ee987ca

Please sign in to comment.