ReviewOS

home-lang/home

Parser: variadic 'args: ...' parameter syntax (3 kernel files)

#49
Closed glennmichael123 opened this 24 days ago · 0 comments
24 days ago

Problem

The parser does not accept the variadic-parameter shape args: ... in a function signature:

export fn kprintf(fmt: &str, args: ...) { ... }
export fn format_message(format: *u8, buffer: *u8, max_len: u32, args: ...): u32 { ... }

Diagnostic: error[EP0001]: Expected type name at the ... token position.

Affected kernel files

  • kernel/src/arch/arm64/rpi/uart.home:894 (fn kprintf(fmt: &str, args: ...))
  • kernel/src/i18n/messages.home:663 (fn format_message(..., args: ...): u32)
  • (potentially more — surfaced as the agent for #46 cleared anon-struct returns)

Expected behavior

Accept args: ... (or args: ...T for typed variadics) as the final parameter of a function signature. Inside the function body, args should be usable as an iterable of un-typed (or typed-T) arguments, lowering to whatever the codegen calling convention prefers (likely a slice or platform va_args).

Notes

  • This is the same shape Zig uses for anytype-style variadics in some forms; or C's ... from <stdarg.h>. The kernel uses it for printf-family functions.
  • If Home's design wants to avoid runtime variadics (preferring comptime tuple unpacking), the answer is: file a kernel-side issue to rewrite these as comptime-tuple. But the kernel author wrote them in args: ... form, suggesting variadic is the intended dialect.

Tests

  • Positive: fn foo(args: ...) {} parses
  • Negative: args: ... not in trailing position (e.g. fn foo(args: ..., x: u32)) yields a clean diagnostic

Acceptance

  1. The 2 listed kernel files clear home-debug ast past the variadic param point.
  2. Existing test suite green.

Sign in to comment on this issue.