Skip to content

Compiler warning W9901 for by-value fixed-size array parameters

Compiler warning W9901 — fixed-size array passed by value

Section titled “Compiler warning W9901 — fixed-size array passed by value”

When a function parameter is declared as a fixed-size array without edit or a leading *, Janus passes it by value. Writes inside the callee are lost, and in some emission contexts the same signature lowered to LLVM emit error: MissingOperand.

As of this release, the compiler emits warning W9901:

warning: W9901: parameter 'buf' is fixed-size array [4096]u8 passed by value; writes inside the function will be lost. Use 'edit buf: [4096]u8' or 'edit buf: *[4096]u8' instead.

To mutate the caller’s array, declare the parameter as edit buf: *[N]T and pass &caller_buf at the call site:

func decU32Le(edit buf: *[4096]u8, pos: usize, value: u32) -> usize do
buf[pos] = as[u8](value & 0xFF)
buf[pos + 1] = as[u8](value >> 8)
buf[pos + 2] = as[u8](value >> 16)
buf[pos + 3] = as[u8](value >> 24)
return pos + 4
end
var pack: [4096]u8 = .{ 71, 80, 75, 49, 0, 0, 0, 2 }
decU32Le(&pack, 4, 2)

This closes Gap 99 in COMPILER_GAPS.md.