Skip to content

modules that depend on themselves cannot be tested  #14708

@leecannon

Description

@leecannon

Zig Version

0.11.0-dev.1782+b52be973d

Steps to Reproduce and Observed Behavior

fn createModule(b: *std.Build) *std.Build.Module {
    const recursive_module = b.createModule(
        .{ .source_file = .{ .path = "module/module.zig" } },
    );

    return b.createModule(.{
        .source_file = .{ .path = "module/module.zig" },
        .dependencies = &.{
            .{ .name = "module", .module = recursive_module },
        },
    });
}

using a function like the above to create a module that can import its own root file worked on version 0.11.0-dev.1711+dc1f50e50 but now results in errors like:

$ zig build run
module/module.zig:1:1: error: file exists in multiple modules
module/module.zig:1:1: note: root of module root.module.module
module/module.zig:1:1: note: root of module root.module

Expected Behavior

It should be possible for a module to import its own root file whether that is supporting this hack that I have been using or something akin to @import("root") like @import("module_root")

This allows modules to have deeply nested structures but not have to use the fragile @import("../../../module_root.zig").thing.i.want

Metadata

Metadata

Assignees

No one assigned

    Labels

    zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions