Skip to content

Syntax error hits unreachable code #354

@Sirius902

Description

@Sirius902

The following source causes ZLS to hit unreachable code (on Windows at least). It's not valid Zig code, but I don't think ZLS should crash because of a syntax error.

pub const Error = error;

pub fn main() void {

}

Here's the trace:

thread 15876 panic: reached unreachable code
D:\Programming\zls\src\offsets.zig:128:35: 0x7ff6e5108ca3 in offsets.tokenRelativeLocation (zls.obj)
                const codepoint = try std.unicode.utf8Decode(source[i .. i + n]);
                                  ^
D:\Programming\zls\src\analysis.zig:1816:68: 0x7ff6e512b2f8 in analysis.getDocumentSymbolsInternal (zls.obj)
    const end_loc = start_loc.add(try offsets.tokenRelativeLocation(
                                                                   ^
D:\Programming\zls\src\analysis.zig:1786:35: 0x7ff6e512bc88 in analysis.addOutlineNodes (zls.obj)
    try getDocumentSymbolsInternal(allocator, tree, child, context);
                                  ^
D:\Programming\zls\src\analysis.zig:1881:40: 0x7ff6e512b827 in analysis.getDocumentSymbolsInternal (zls.obj)
                    try addOutlineNodes(allocator, tree, var_decl.ast.init_node, &child_context);
                                       ^
D:\Programming\zls\src\main.zig:1708:53: 0x7ff6e509a7f4 in processJsonRpc (zls.obj)
                    done = extractErr(method_info[2](arena, id, request_obj, config));
                                                    ^
D:\Programming\zls\src\main.zig:1949:27: 0x7ff6e505ea7a in main (zls.obj)
        try processJsonRpc(&arena, &json_parser, buf, config);
                          ^
D:\Programming\zig\lib\zig\std\start.zig:267:65: 0x7ff6e50566b1 in std.start.WinStartup (zls.obj)
    std.os.windows.kernel32.ExitProcess(initEventLoopAndCallMain());
                                                                ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions