Skip to content

Compiler panic when .emit_docs in build.zig is combined with a bad @import #13512

Closed
@verdog

Description

@verdog

Zig Version

0.11.0-dev.137+e40c38d25

Steps to Reproduce and Observed Behavior

Make a zig project with these files:

build.zig

const std = @import("std");

pub fn build(b: *std.build.Builder) void {
    const target = b.standardTargetOptions(.{});
    const mode = b.standardReleaseOptions();

    const exe = b.addExecutable("main", "src/main.zig");
    exe.emit_docs = .emit; // boom
    exe.setTarget(target);
    exe.setMainPkgPath("./src");

    exe.setBuildMode(mode);
    exe.install();
}

src/main.zig

const Nothing = @import("none"); // this doesn't exist

pub fn main() !void {}

And run zig build:

⇒  zig build
thread 26970 panic: attempt to unwrap error: PackageNotFound
Unable to dump stack trace: debug info stripped
error: main...
error: The following command terminated unexpectedly:
/opt/zig/zig-linux-x86_64-0.11.0-dev.137+e40c38d25/zig build-exe /tmp/rep/src/main.zig -femit-docs --cache-dir /tmp/rep/zig-cache --global-cache-dir /home/josh/.cache/zig --name main --main-pkg-path /tmp/rep/src --enable-cache 
error: the following build command failed with exit code 6:
/tmp/rep/zig-cache/o/f6b591257cb6359f87ccd16bf93f70bb/build /opt/zig/zig-linux-x86_64-0.11.0-dev.137+e40c38d25/zig /tmp/rep /tmp/rep/zig-cache /home/josh/.cache/zig

This does not happen when the .emit_docs line in build.zig is removed.

Expected Behavior

The compiler should not crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    autodocThe web application for interactive documentation and generation of its assets.bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions