Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate top-module input #8005

Merged
merged 3 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased
----------

- Validate path for `$ dune ocaml top-module`. (#8005, fixes #8004, @3Rafal)

- Include the time it takes to read/write state files when `--trace-file` is
enabled (#7960, @rgrinberg)

Expand Down
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
rgrinberg marked this conversation as resolved.
Show resolved Hide resolved
Expand Down