Skip to content

compile: no module search-path / project build mode — nested src/** use SiblingModule fails #642

Open

Description

@hyperpolymath

Summary

The core-WASM compile command is single-file only — it has no module search path, so a nested src/** project layout where one module does use SiblingModule fails to resolve ("undefined module"). Downstream, the svalinn gateway (stapeln/container-stack/svalinn/src) cannot be compiled as a project.

Evidence

affinescript compile exposes only [--target TRIPLE] FILE [-o OUT] (bin/main.ml, the compile term is target_arg $ path_arg $ output_arg). There is no --search-path / project / manifest option, and the Module_loader is built from defaults, so a use SiblingModule referencing another file under src/ relative to the entry file is not found.

Suggested direction

Either:

  • a repeatable --search-path DIR flag threaded into the Module_loader config used by compile, or
  • a project/manifest build mode (compile a directory / a manifest) that roots module search at the project src/.

Context

Surfaced while characterising svalinn-gateway compiler gaps after the cross-module constructor-link fix (#138 / #602, ac98c81). This is a separate gap — module resolution at compile time, not constructor codegen. Confirmed at main b8ba479.

Activity

  1. added
    bugSomething is broken or behaves incorrectly
    on Aug 27, 2026
  2. hyperpolymath commented on Nov 21, 2026

    @hyperpolymath
    OwnerAuthor

    Checked on main at 70379fe (21 Nov). This gap appears to be closed already, by the loader work in #788 / #797.

    What is on main now

    • Module_loader.config_for_file roots module search at the package root (from the file's module A.B; declaration) and keeps the file's own directory on the search path. Every CLI command, compile included, builds its loader through loader_config_for_file in bin/main.ml.
    • $AFFINESCRIPT_PATH (colon-separated) adds extra search directories. That covers the "repeatable --search-path" suggestion, without a new flag.
    • Unit test sibling_import_from_nested in test/test_module_root_flatten.ml covers the nested sibling case.

    What I ran locally (OCaml 4.14.1, dune 3.14)

    • test_main.exe: 589 tests, all pass.
    • affinescript compile on a nested src/ project, run from an unrelated working directory:
      • src/Main.affine with use Helper::{h}; (sibling src/Helper.affine): compiles to WASM.
      • src/gateway/Server.affine (module gateway.Server;) with use Route::{r}; (short sibling): compiles.
      • the same file with use gateway.Route2::{r}; plus use Helper::{h}; (full path and package-root module): compiles.
      • A file that declares module Route; but is imported as gateway.Route is refused with a resolution error. That is the intended declared-path check, not this bug.

    Caveat

    CI has not started on main since 11 Oct (fixed by #803), so none of this has run in CI yet. I suggest that you merge #803, let CI run on main, and then close this issue. The svalinn gateway itself was not tested here.

    No code change proposed, so no PR.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaves incorrectlypriority:p2Normal - queue itscope:repoConfined to this repositorystatus:readyFully specified and ready to be picked up

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions