Skip to content

dune ocaml top-module crashes when file doesn't have .ml extension or is directory #8004

@3Rafal

Description

@3Rafal

Expected Behavior

When passing invalid output to top-module I expect error message that explains the problem

Actual Behavior

rafal@machine ocaml-lsp % dune ocaml top-module dune
Error: exception Invalid_argument("Filename.chop_extension")
Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
Called from Main__top.Module.module_directives in file "bin/ocaml/top.ml",
  line 106, characters 17-70
Called from Main__top.Module.term.(fun) in file "bin/ocaml/top.ml", line 229,
  characters 14-48
Called from Fiber__scheduler.exec in file "otherlibs/fiber/src/scheduler.ml",
  line 73, characters 8-11

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases.
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.

Reproduction

Pass to dune ocaml top-module directory or file without .ml extension

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions