Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
verdog opened this issue Nov 11, 2022 · 1 comment · Fixed by #19208
Closed

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

verdog opened this issue Nov 11, 2022 · 1 comment · Fixed by #19208
Labels
autodoc The web application for interactive documentation and generation of its assets. bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@verdog
Copy link
Contributor

verdog commented Nov 11, 2022

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.

@verdog verdog added the bug Observed behavior contradicts documented or intended behavior label Nov 11, 2022
@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Nov 11, 2022
@Vexu Vexu added this to the 0.11.0 milestone Nov 11, 2022
@Vexu Vexu added the autodoc The web application for interactive documentation and generation of its assets. label Nov 11, 2022
@orhun
Copy link
Sponsor

orhun commented Apr 20, 2023

I just experienced the same and I would like to work on fixing this if the expected behavior is made clear. Do we only want the compiler to not crash and possibly show an error message that the import doesn't exist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autodoc The web application for interactive documentation and generation of its assets. bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants