{"record":{"id":"640f29d18f3c6765","repo":"oxc-project/oxc","slug":"encountered-allocation-error","errorCode":null,"errorMessage":"encountered allocation error","messagePattern":"encountered allocation error","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_allocator/src/vec2/raw_vec.rs","lineNumber":871,"sourceCode":"// ensure that the code generation related to these panics is minimal as there's\n// only one location which panics rather than a bunch throughout the module.\n#[cold]\n#[inline(never)]\nfn capacity_overflow() -> ! {\n    panic!(\"capacity overflow\")\n}\n\n/// Handle collection allocation errors\n///\n// Causing a collection alloc error is rare case, so marked as `#[cold]` and `#[inline(never)]`\n// to make the call site function as small as possible, so it can be inlined.\n#[inline(never)]\n#[cold]\nfn handle_error(error: AllocError) -> ! {\n    match error {\n        AllocError::CapacityOverflow => capacity_overflow(),\n        // TODO: call `handle_alloc_error` instead of `panic!` once the AllocErr stored a Layout,\n        AllocError::AllocErr => panic!(\"encountered allocation error\"),\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use crate::arena::Arena;\n\n    use super::*;\n\n    #[test]\n    fn reserve_does_not_overallocate() {\n        let arena = Arena::new();\n        {\n            let mut v: RawVec<u32, _> = RawVec::new_in(&arena);\n            // First `reserve` allocates like `reserve_exact`\n            v.reserve(0, 9);\n            assert_eq!(9, v.capacity_u32());\n        }","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_allocator/src/vec2/raw_vec.rs#L853-L889","documentation":"Diagnostic from oxlint's vue/require-typed-ref rule (crates/oxc_linter/src/rules/vue/require_typed_ref.rs), which runs only on TypeScript sources. `ref()` or `shallowRef()` called with no type parameter and no meaningful initial value produces `Ref<any>`, bypassing `noImplicitAny`. The rule reports such calls; a type annotation on the declaring variable also satisfies it.","triggerScenarios":"In TS files (or `lang=\"ts\"` script blocks): `const count = ref();`, `const n = shallowRef();`, or a first argument of `null`/`undefined` (`ref(null)`, `shallowRef(undefined)`) with no type arguments. Passing any real initial value, adding a type parameter (`ref<number>()`), or annotating the variable (`const x: Ref<number> = ...`) avoids the report.","commonSituations":"Optional state initialized to null and filled later; strict-mode TS codebases plugging `Ref<any>` leaks; refs that hold API data typed only at assignment sites.","solutions":["Pass an initial value: `const count = ref(0)`.","Or add a type parameter: `const user = ref<User | null>(null)`.","Or annotate the variable: `const user: Ref<User | null> = ref(null);`.","For deliberately untyped refs, disable the rule inline with a comment."],"exampleFix":"// before\nconst user = ref();\nconst total = shallowRef(null);\n\n// after\nconst user = ref<User | null>(null);\nconst total = shallowRef(0);","handlingStrategy":"type-guard","validationCode":"// create refs through a helper that refuses bare calls\nimport { ref, type Ref } from 'vue';\nconst typedRef = <T,>(): Ref<T> => ref<T>();\n// const bad = ref();        // replace with typedRef<User | null>()","typeGuard":"// compile-time guard: `any` satisfies 0 extends 1 & T, so Ref<any> maps to never\nimport type { Ref } from 'vue';\ntype NoAny<T> = 0 extends 1 & T ? never : T;\nfunction assertTyped<T>(r: Ref<NoAny<T>>): Ref<T> {\n  return r as Ref<T>;\n}\n// const bad = assertTyped(ref());        // compile error\n// const ok = assertTyped(ref<number>()); // fine","tryCatchPattern":null,"preventionTips":["Never write bare ref()/shallowRef() in TS; always ref(value) or ref<Type>().","Keep noImplicitAny on so downstream use of Ref<any> also surfaces.","Enable vue/require-typed-ref for .ts and lang=ts files in the oxlint config."],"tags":["vue","oxlint","lint","typescript","ref","reactivity","type-safety"],"backgroundTag":"vue-untyped-ref","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}