{"record":{"id":"8fca36b1d88d3839","repo":"oxc-project/oxc","slug":"pronoun-name-is-assigned-a-value-but-never-u","errorCode":null,"errorMessage":"{pronoun} '{name}' is assigned a value but never used.{suffix}","messagePattern":"(.+?) '(.+?)' is assigned a value but never used\\.(.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs","lineNumber":101,"sourceCode":"    })\n    .with_label(symbol.span().label(format!(\"'{name}' is declared here\")))\n    .with_help(help)\n}\n\n/// Variable 'x' is assigned a value but never used.\npub fn assign<R>(\n    symbol: &Symbol<'_, '_>,\n    assign_span: Span,\n    pat: &IgnorePattern<R>,\n) -> OxcDiagnostic\nwhere\n    R: fmt::Display,\n{\n    let name = symbol.name();\n    let (pronoun, pronoun_plural) = pronoun_for_symbol(symbol.flags());\n    let suffix = pat.diagnostic_help(pronoun_plural);\n\n    OxcDiagnostic::warn(format!(\"{pronoun} '{name}' is assigned a value but never used.{suffix}\"))\n        .with_labels([\n            symbol.span().label(format!(\"'{name}' is declared here\")),\n            assign_span.label(\"it was last assigned here\"),\n        ])\n        .with_help(\"Did you mean to use this variable?\")\n}\n\n/// Parameter 'x' is declared but never used.\npub fn param<R>(\n    symbol: &Symbol<'_, '_>,\n    pat: &IgnorePattern<R>,\n    only_used_as_type: bool,\n) -> OxcDiagnostic\nwhere\n    R: fmt::Display,\n{\n    let name = symbol.name();\n    let suffix = if name == \"_\" && pat.is_default() {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs#L83-L119","documentation":"no-unused-vars dead-store message: a value is assigned to an already-declared variable and that particular value is never read afterward (it is overwritten first, or its scope/function ends). Distinct from 'never used': the variable exists, but this stored value is wasted. Two labels point at the declaration and at the dead assignment.","triggerScenarios":"let x = 1; x = compute(); use(x); where the first store is dead; an assignment immediately before a return/throw that never reads it; assignments in a branch that then exits without merging.","commonSituations":"Accumulator variables rebuilt by wholesale reassignment; initialization 'just in case'; assignments left behind after the last consumer was removed.","solutions":["Delete the assignment whose stored value is never read.","Hoist to a single const at the point of first use.","If the right-hand side has needed side effects, keep the call but discard its result deliberately and visibly."],"exampleFix":"// before\nlet total;\ntotal = computeBase();\ntotal = computeBase() + extra;\nuse(total);\n// after\nconst total = computeBase() + extra;\nuse(total);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer const at the point of first use over declare-then-assign.","When adding an early return, check whether assignments above it are still read.","Review wholesale reassignments of accumulators; they usually make earlier stores dead."],"tags":["eslint","oxlint","unused-vars","dead-store","dataflow"],"backgroundTag":"dead-store-assignment","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}