E0907: Function frame too large
| Code | Category | Stability |
|---|---|---|
E0907 | Array | Permanent |
Explanation
Every function's storage is addressed by signed 32-bit displacements from its frame pointer, so the cumulative storage of one function is limited to 2,147,483,632 bytes — the largest 16-byte-aligned value inside that range (C.4:3). Locals, parameter homes, hidden return storage, register-allocation spills, and the simultaneous outgoing call area all draw on that one checked budget, and E0907 reports the reservation that would take it over; the message names the byte ceiling. The budget is cumulative, which is what distinguishes E0907 from E0906: each individual type in the function may be within the object-size ceiling of 268,435,455 slots and the function still be rejected because their sum is not. The check runs during semantic analysis, before any machine code is generated, so it is the same on every supported target.
Likely cause
One very large frame-resident object, or many merely large ones in the same body, exceeded the function's storage budget. Shrink the largest local — an array length is usually the driver — or split the body so that separately-lived objects live in separate functions rather than sharing one frame. A large object passed by value is reserved twice over — once in the caller's outgoing call area and again in the callee's parameter home — while a borrow parameter costs one pointer-sized slot in each.
Examples
A local one slot past the frame budget
fn main() -> i32 {
let xs: [[i8; 16383]; 16385] = [[0; 16383]; 16385];
0
}
Keep the frame inside the budget
fn main() -> i32 {
let xs: [[i8; 1024]; 16] = [[0; 1024]; 16];
@intCast(xs[0][0])
}