Problem
The parser fails on Zig-style typed array literals when the element type is namespaced (i.e. module.Type):
const mouse_id_table = [_]usb.USBDeviceID {
usb.USBDeviceID { .match_flags = ..., .bInterfaceClass = usb.USB_CLASS_HID, ... },
...
};Diagnostic: error[EP0001]: Expected semicolon or newline between statements at the { after the namespaced type.
The parser appears to:
- Parse
[_]usb.USBDeviceIDas a complete expression (possibly the array-type or the field access intoUSBDeviceID) - Then see the
{and not recognize it as the start of an array-literal initializer body - Bail with the "expected semicolon" diagnostic because it thinks the previous statement should be terminated.
Affected kernel files
- kernel/src/drivers/input/mouse.home:112 (
[_]usb.USBDeviceID { ... }) - kernel/src/drivers/input/gamepad.home:195 (
[_]usb.USBDeviceID { ... }) - kernel/src/iot/conversation.home:377 (
[_][]const u8 { "it", "they", ... }) - kernel/src/net/bluetooth_pan.home:167 (
[_]NetworkTypeFilter{...} ** 16— also tests array-repeat**)
Verification needed
- Does
[_]u8{1, 2, 3}(non-namespaced) work today? If yes, the bug is specific to the dotted-type path. If no, the bug is broader. - Does
[_][]const u8 { ... }(slice-of-slice element) work today?
Expected behavior
Both forms should parse:
const a = [_]u8{1, 2, 3}; // primitive element
const b = [_]Foo{ Foo{ .x = 1 } }; // local typed element
const c = [_]ns.Foo{ ns.Foo{ .x = 1 } }; // namespaced typed element ← currently fails
const d = [_][]const u8{ \"a\", \"b\" }; // slice element
const e = [_]Foo{ Foo{...} } ** 16; // with array-repeatImplementation hint
In the array-type / array-literal parser path, after consuming [_] and the type expression, peek for { to dispatch into array-literal initializer parsing. The current code likely commits to "this is an expression statement" too early.
Look for the divergence between the parser's handling of [_]Type vs [_]ns.Type — the latter probably ends up in parsePostfixExpression (member access) instead of parseArrayType/parseArrayLiteral.
Tests
- Positive: each of the 5 forms above
- Regression: existing
[_]u8{ ... }(non-namespaced) keeps working
Acceptance
- The 4 listed kernel files clear
home-debug ast. - Existing test suite green.