fix(lsp): identifier array dimension no longer panics the analyzer [0099]
`Analyzer.resolveTypeNode` read the array `.length` node's `.int_literal` union field unconditionally. For a named-const dimension (`MAX :: 4; [MAX]u8`) that node is an `identifier`, so the access tripped Zig's checked-union panic and `sx lsp` aborted on didOpen. The main compiler was unaffected (it folds the dim through the IR). - New `arrayDimLength` helper switches on the dimension node tag: int_literal → value; identifier → a recorded module-const int value; anything else / out-of-u32-range → unknown. Never assumes a node shape. - `Type.ArrayTypeInfo.length` is now `?u32`; null is an explicit "editor couldn't fold this dimension" marker (rendered `[_]T`), never a fabricated concrete length. - New `const_int_values` registry records integer-literal consts at registration time for the identifier path. Regression: first `src/lsp/*.test.zig` (the minimal LSP harness), wired into the test graph via `src/root.zig`. Drives `analyzeDocument` over `[MAX]u8` (folds to 4, no panic), `[64]u8` (happy-path guard), and `[N]u8` (explicit unknown). Fail-before/pass-after verified. Sibling audit of the resolveTypeNode/fieldType family: the array dim was the only unchecked union-field access; all other arms recurse or tag-check first. Noted a non-crashing display gap in server.zig hover rendering for step B.
This commit is contained in:
@@ -22,6 +22,7 @@ pub const lsp = struct {
|
||||
pub const transport = @import("lsp/transport.zig");
|
||||
pub const types = @import("lsp/types.zig");
|
||||
pub const document = @import("lsp/document.zig");
|
||||
pub const document_tests = @import("lsp/document.test.zig");
|
||||
};
|
||||
|
||||
test {
|
||||
@@ -35,6 +36,7 @@ test {
|
||||
// struct deeper, so reference them directly to pull in their tests.
|
||||
_ = lsp.server;
|
||||
_ = lsp.document;
|
||||
_ = lsp.document_tests;
|
||||
_ = lsp.types;
|
||||
_ = lsp.transport;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user