oxc-project/oxc · error · OxcDiagnostic
Lacked a call of `super()` in some code paths.
Error message
Lacked a call of `super()` in some code paths.
What it means
The missing_super_some variant of constructor-super (crates/oxc_linter/src/rules/eslint/constructor_super.rs:26). It fires when super() is called on at least one path but the control-flow graph still shows a path from constructor entry to exit with no super() call. Typical shape: super() only inside an `if` without a covering `else`, or inside a loop/try that may skip it; the missing call makes `this` (and instantiation) fail on that path.
Source
Thrown at crates/oxc_linter/src/rules/eslint/constructor_super.rs:27
Direction,
visit::{EdgeRef, neighbors_filtered_by_edge_weight},
},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::NodeId;
use oxc_span::{GetSpan, Span};
use crate::{AstNode, context::LintContext, rule::Rule};
fn missing_super_all(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Expected to call `super()`.")
.with_help("Add a `super()` call to the constructor")
.with_label(span)
}
fn missing_super_some(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Lacked a call of `super()` in some code paths.")
.with_help("Ensure `super()` is called in all code paths")
.with_label(span)
}
fn duplicate_super(span: Span, first_super_span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected duplicate `super()`.")
.with_help("Remove the duplicate `super()` call")
.with_labels([
span.primary_label("This path may call `super()` after it was already called."),
first_super_span.label("`super()` was first called here."),
])
}
#[derive(Clone, Copy)]
struct SuperClassContext {
span: Span,
label: &'static str,
}View on GitHub (pinned to e1e7af627c)
Solutions
- Hoist a single unconditional `super()` to the top of the constructor, before any branching.
- Restructure so all conditional logic runs after the one super() call.
- Pass conditional arguments instead of branching the call: `super(x ?? defaults)`.
Example fix
// before
constructor(enabled) {
if (enabled) super();
this.enabled = enabled;
}
// after
constructor(enabled) {
super();
this.enabled = enabled;
} Defensive patterns
Strategy: validation
Validate before calling
// .oxlintrc.json
{
"rules": {
"constructor-super": "error"
}
} Prevention
- Always place one unconditional super() as the first statement of derived constructors.
- Keep argument validation after super(), not around it.
- Pass conditional values (`super(x ?? d)`) instead of branching the call itself.
When it happens
Trigger: A constructor like `constructor(x) { if (x) super(); this.x = 1; }` — any conditional, early-return, or wrapping control flow that leaves a path without super().
Common situations: Calling super conditionally after argument validation; refactoring constructors around feature flags; moving super() inside a try/catch for error handling.
Related errors
- Expected to call `super()`.
- Redundant super call in constructor
- Unexpected duplicate `super()`.
- Unexpected `super()` because `super` is not a constructor.
- Expected to always call `super()` before `this`/`super` prop
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/a0bb1cbf89f640f9.
Report an issue: GitHub.