Skip to content

unreachable error.FileNotFound when client sends didOpen on a file that doesnt exist #2609

@xdBronch

Description

@xdBronch

Zig Version

0.16.0-dev.2552+6c7814fab

ZLS Version

0.16.0-dev.215+0e289f5c

Client / Code Editor / Extensions

NVIM v0.12.0-dev-2060+gf36dd7557a/zed 0.225

Steps to Reproduce and Observed Behavior

// foo.zig
const bar = @import("bar.zig");

:e bar.zig in nvim

thread 22260 panic: attempt to unwrap error: FileNotFound
error return context:
/home/user/dev/zls/src/DocumentStore.zig:512:13: 0x1348dc6 in await (zls.zig)
            return f.err orelse return &f.handle;
            ^
/home/user/dev/zls/src/DocumentStore.zig:1427:50: 0x1547809 in createAndStoreDocument (zls.zig)
                if (options.override and !retry) return err;
                                                 ^

stack trace:
/home/user/dev/zls/src/DocumentStore.zig:792:17: 0x1473372 in openLspSyncedDocument (zls.zig)
        else => unreachable,
                ^
/home/user/dev/zls/src/Server.zig:1150:52: 0x1412250 in openDocumentHandler (zls.zig)
    try server.document_store.openLspSyncedDocument(document_uri, notification.textDocument.text);
                                                   ^
/home/user/dev/zls/src/Server.zig:1824:67: 0x13c9dfe in sendNotificationSync__anon_48512 (zls.zig)
        .@"textDocument/didOpen" => try server.openDocumentHandler(arena, params),
                                                                  ^

this might be a bug in nvim, it seems pretty odd for it to do what its doing, but ZLS shouldnt be crashing because of it. i also managed to reproduce this in zed with the exact same steps

Expected Behavior

dont crash perchance

Attach ZLS log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions