Problem
The parser rejects anonymous struct types when they appear as a function return type:
export fn getCursor(): struct { x: usize, y: usize } {
return .{ .x = column, .y = row }
}Diagnostic: error[EP0001]: Expected type name.
The parser's return-type slot only accepts named types and certain primitive constructions; it doesn't recurse into a full type expression, so struct { ... } is not recognized.
Affected kernel files
- kernel/src/vga.home:213
- kernel/src/heap.home:169
- kernel/src/i18n/messages.home:663
(Subset of the 7-file 'Expected type name' bucket. The other 4 are different root causes — extern \"C\" fn(...) etc. — and will be filed separately if they cluster.)
Expected behavior
In return-type position, accept the same type grammar as in let x: T = ... annotations, including:
struct { f1: T1, f2: T2 }(anonymous struct)- nested generics, pointers, optionals, etc. that already work elsewhere
The returned struct-literal .{ .x = ..., .y = ... } should continue to coerce into the inferred anonymous struct type.
Implementation hint
Likely a one-line change in the return-type parsing path to call the full parseType entry point instead of parseTypeName/parsePrimitiveTypeName.
Tests to add
- Positive: anonymous struct return type with inferred field order
- Negative: malformed anonymous struct (missing field type) yields a clean diagnostic
Acceptance
- The 3 listed kernel files clear
home-debug ast. - Existing test suite green.