From 4a78852dc877e1ad945868bce57b62738e0bd02e Mon Sep 17 00:00:00 2001 From: Khang Nguyen Duy Date: Sun, 8 Nov 2026 14:59:20 +0700 Subject: [PATCH] fix completion crash on unknown tagged union payload type --- src/analyser/InternPool.zig | 2 +- tests/lsp_features/completion.zig | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/analyser/InternPool.zig b/src/analyser/InternPool.zig index e050203cc..d8953ad33 100644 --- a/src/analyser/InternPool.zig +++ b/src/analyser/InternPool.zig @@ -3655,7 +3655,7 @@ pub fn onePossibleValue(ip: *InternPool, ty: Index) Index { .type_info, => Index.none, - .unknown => unreachable, + .unknown => Index.unknown_unknown, .generic_poison => unreachable, }, .int_type => |int_info| { diff --git a/tests/lsp_features/completion.zig b/tests/lsp_features/completion.zig index b21dac8a7..d26609e1a 100644 --- a/tests/lsp_features/completion.zig +++ b/tests/lsp_features/completion.zig @@ -1867,6 +1867,18 @@ test "tagged union - tag" { }); } +test "tagged union - unknown field type" { + try testCompletion( + \\const UnknownType: type; + \\const U = union(enum) { + \\ alpha: UnknownType, + \\}; + \\const foo: U = . + , &.{ + .{ .label = "alpha", .kind = .Field }, + }); +} + test "switch cases" { // Because current logic is to list all enums if all else fails, // the following tests include an extra enum to ensure that we're not just 'getting lucky'