Skip to content

cimport crashes due to Zig not respecting --enable-cache #1080

@leecannon

Description

@leecannon

Zig Version

0.11.0-dev.2191+30427ff79

Zig Language Server Version

0.11.0-dev.332+a929576

Steps to Reproduce

start typing inside main:

const std = @import("std");

pub fn main() !void {
    
}

usingnamespace @cImport({});

Expected Behavior

no crash

Actual Behavior

debug: (store ): Translated cImport into file://pub const __builtin_bswap16 %3D %40import%28"std"%29.zig.c_builtins.__builtin_bswap16%3B
thread 46379 panic: reached unreachable code
/home/lee/zig/0.11.0-dev.2191+30427ff79/files/lib/std/debug.zig:281:14: 0x34a52c in assert (zls)
    if (!ok) unreachable; // assertion failure
             ^
/home/lee/zig/0.11.0-dev.2191+30427ff79/files/lib/std/fs.zig:2729:27: 0x354eaa in openFileAbsolute (zls)
    assert(path.isAbsolute(absolute_path));
                          ^
/home/lee/src/zls/src/DocumentStore.zig:796:39: 0x5e88f1 in createDocumentFromURI (zls)
    var file = std.fs.openFileAbsolute(file_path, .{}) catch return null;
                                      ^
/home/lee/src/zls/src/DocumentStore.zig:135:47: 0x5e84ff in getOrLoadHandleInternal (zls)
    handle.* = (try self.createDocumentFromURI(uri, false)) orelse return error.Unknown; // error name doesn't matter
                                              ^
/home/lee/src/zls/src/DocumentStore.zig:126:40: 0x54e400 in getOrLoadHandle (zls)
    return self.getOrLoadHandleInternal(uri) catch null;
                                       ^
/home/lee/src/zls/src/analysis.zig:1057:66: 0x4c6988 in resolveTypeOfNodeUncached (zls)
                const new_handle = analyser.store.getOrLoadHandle(cimport_uri) orelse return null;
                                                                 ^
/home/lee/src/zls/src/analysis.zig:675:63: 0x4376c6 in resolveTypeOfNodeInternal (zls)
    const type_handle = try analyser.resolveTypeOfNodeUncached(node_handle);
                                                              ^
/home/lee/src/zls/src/analysis.zig:2149:63: 0x5cc3a7 in iterateSymbolsGlobalInternal__anon_56308 (zls)
                .{ .node = handle.tree.nodes.items(.data)[use].lhs, .handle = handle },
                                                              ^
/home/lee/src/zls/src/analysis.zig:2174:53: 0x53b949 in iterateSymbolsGlobal__anon_48789 (zls)
    return try analyser.iterateSymbolsGlobalInternal(handle, source_index, callback, context);
                                                    ^
/home/lee/src/zls/src/features/completions.zig:495:45: 0x4c0bfa in completeGlobal (zls)
    try server.analyser.iterateSymbolsGlobal(handle, pos_index, declToCompletion, context);
                                            ^
/home/lee/src/zls/src/features/completions.zig:836:50: 0x435ea5 in completionAtIndex (zls)
        .var_access, .empty => try completeGlobal(server, source_index, handle),
                                                 ^
/home/lee/src/zls/src/Server.zig:1098:45: 0x3f4792 in completionHandler (zls)
    return try completions.completionAtIndex(server, source_index, handle);
                                            ^
/home/lee/src/zls/src/Server.zig:1756:35: 0x3af591 in processMessage (zls)
                break :blk handler(server, params) catch |err| {
                                  ^
/home/lee/src/zls/src/Server.zig:1613:26: 0x35bf7a in processJsonRpc (zls)
    server.processMessage(message) catch |err| switch (message) {
                         ^
/home/lee/src/zls/src/main.zig:80:30: 0x35b73b in loop (zls)
        server.processJsonRpc(json_message);
                             ^
/home/lee/src/zls/src/main.zig:395:13: 0x35cb08 in main (zls)
    try loop(server, record_file, replay_file);
            ^
/home/lee/zig/0.11.0-dev.2191+30427ff79/files/lib/std/start.zig:617:37: 0x344efe in posixCallMainAndExit (zls)
            const result = root.main() catch |err| {
                                    ^
/home/lee/zig/0.11.0-dev.2191+30427ff79/files/lib/std/start.zig:376:5: 0x344961 in _start (zls)
    @call(.never_inline, posixCallMainAndExit, .{});
    ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:highHigh priority item

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions