oxc-project/oxc · warning
capacity overflow
Error message
capacity overflow
What it means
Diagnostic from oxlint's vue/require-slots-as-functions rule (crates/oxc_linter/src/rules/vue/require_slots_as_functions.rs). In Vue 3 each entry of `this.$slots` is a function returning VNodes (in Vue 2 it was a VNode or array). Using a slot as a plain property — rendering or passing `this.$slots.default` without calling it — breaks under Vue 3. The rule flags member reads on `$slots` (via `this`-object analysis in component options) that are not invoked as functions.
Source
Thrown at crates/oxc_allocator/src/vec2/raw_vec.rs:858
#[inline]
fn alloc_guard(alloc_size: usize) -> Result<(), AllocError> {
if size_of::<usize>() < 8 {
if alloc_size > isize::MAX as usize {
return Err(AllocError::CapacityOverflow);
}
} else if alloc_size > u32::MAX as usize {
return Err(AllocError::CapacityOverflow);
}
Ok(())
}
// One central function responsible for reporting capacity overflows. This'll
// ensure that the code generation related to these panics is minimal as there's
// only one location which panics rather than a bunch throughout the module.
#[cold]
#[inline(never)]
fn capacity_overflow() -> ! {
panic!("capacity overflow")
}
/// Handle collection allocation errors
///
// Causing a collection alloc error is rare case, so marked as `#[cold]` and `#[inline(never)]`
// to make the call site function as small as possible, so it can be inlined.
#[inline(never)]
#[cold]
fn handle_error(error: AllocError) -> ! {
match error {
AllocError::CapacityOverflow => capacity_overflow(),
// TODO: call `handle_alloc_error` instead of `panic!` once the AllocErr stored a Layout,
AllocError::AllocErr => panic!("encountered allocation error"),
}
}
#[cfg(test)]
mod tests {View on GitHub (pinned to e1e7af627c)
Solutions
- Invoke the slot: `this.$slots.default?.()`.
- When only testing presence, `!!this.$slots.default` is fine, but rendering must call it.
- In setup-style code use `const slots = useSlots(); slots.default?.()` for the same access.
Example fix
// before
render() { return h('div', this.$slots.default); }
// after
render() { return h('div', this.$slots.default?.()); } Defensive patterns
Strategy: validation
Validate before calling
// warn on $slots member reads that are not immediately called
const re = /\$slots\.[A-Za-z_$][\w$]*(\?)?\s*(?!\()/g;
for (const m of source.matchAll(re)) {
console.warn(`call the slot function: ${m[0]}()`);
} Prevention
- Treat every $slots member as a function in Vue 3 code.
- Use useSlots() and the optional-call form `slots.default?.()`.
- Enable the vue3-migration ruleset when upgrading from Vue 2.
When it happens
Trigger: Inside a Vue component options object (methods, computed, render): `this.$slots.default` used as a value, e.g. `h('div', this.$slots.default)` or `renderIt(this.$slots.default)` without a call. The correct form is `this.$slots.default?.()`.
Common situations: Vue 2 to Vue 3 migrations where slots were arrays/vnodes; render functions and functional components reading slots; library code that supported both Vue versions.
Related errors
- Cannot create a `NonEmptyStack` from an empty iterator
- Change to `throw new TypeError(...)`
- Could not find the reuseWorker option in ${path}
- `VirtualFree` failed during cleanup: {err}
- `VirtualFree` failed: {err}
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/38f7d31b47083136.
Report an issue: GitHub.