Skip to content

fix(include-qualified): delay module path evaluation#13156

Merged
anmonteiro merged 3 commits intoocaml:mainfrom
anmonteiro:anmonteiro/module-name-unchecked
Jan 2, 2026
Merged

fix(include-qualified): delay module path evaluation#13156
anmonteiro merged 3 commits intoocaml:mainfrom
anmonteiro:anmonteiro/module-name-unchecked

Conversation

@anmonteiro
Copy link
Copy Markdown
Collaborator

better alternative to #13146

  • introduce Module_name.Unchecked.t, which represents a source module that hasn't been included in any stanzas
  • Module_name.Unchecked.t becomes Module_name.t after calling Module_name.Unchecked.validate_exn, which is called when a module is included in a module group.

closes #7628
refs #7605, which should be trivial to implement on top of this

(** Represents a valid OCaml module name *)
type t

module Unchecked : sig
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a brief summary of this module

@rgrinberg
Copy link
Copy Markdown
Member

Looking back at the original ticket issue, I'm not yet convinced that delaying the errors is the right approach. What if we allow users to just list the directories they want to be included? I.e.

(include_subdirs
 (kind qualified)
 (dirs * \ bar-baz))

I think it would be a smaller change, and also a useful other in other contexts.

@anmonteiro anmonteiro force-pushed the anmonteiro/module-name-unchecked branch from 8429c25 to 1e2cd8b Compare January 1, 2026 20:39
@anmonteiro
Copy link
Copy Markdown
Collaborator Author

anmonteiro commented Jan 2, 2026

I'm not yet convinced that delaying the errors is the right approach.

I disagree because of the case in #7628:

$ tree
.
├── foo
│   └── bar.ml
├── invalid-module-name
│   └── opaque.txt
├── dune
├── dune-project
└── x.ml

IMO there's no reason why the above should fail if you have an unrelated directory that won't contain OCaml sources.

I think specifying directories renaming module interfaces is definitely useful, but I consider it to be an additional feature, not a replacement.

@anmonteiro anmonteiro force-pushed the anmonteiro/module-name-unchecked branch 2 times, most recently from 4688aef to b0f46ca Compare January 2, 2026 04:55
@rgrinberg
Copy link
Copy Markdown
Member

So if you were to modify #7628 so that invalid-module-name contained an .ml file, the error would not be delayed? By delayed, I mean that building some other target in the same directory as the library would not trigger this error.

@anmonteiro anmonteiro force-pushed the anmonteiro/module-name-unchecked branch from b0f46ca to d8dd664 Compare January 2, 2026 11:12
@anmonteiro
Copy link
Copy Markdown
Collaborator Author

So if you were to modify #7628 so that invalid-module-name contained an .ml file, the error would not be delayed? By delayed, I mean that building some other target in the same directory as the library would not trigger this error.

I pushed d8dd664 to show that the error isn't delayed in that case.

@rgrinberg
Copy link
Copy Markdown
Member

To make that test-case more bullet proof, could you build something trivial defined with a rule stanza instead of an empty library? It probably won't make a difference, but I'd be a bit more confident.

@anmonteiro
Copy link
Copy Markdown
Collaborator Author

Just pushed a commit doing that

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
@anmonteiro anmonteiro force-pushed the anmonteiro/module-name-unchecked branch from c606193 to 4372696 Compare January 2, 2026 22:54
@anmonteiro anmonteiro merged commit 7e004fb into ocaml:main Jan 2, 2026
30 checks passed
@anmonteiro anmonteiro deleted the anmonteiro/module-name-unchecked branch January 2, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: (data_only_dirs) should hide directories from (include_subdirs qualified)

2 participants