oxc-project/oxc · error
get string content
Error message
get string content
What it means
Panic inside KnownMemberExpressionProperty::name: for expression elements the method extracts static string content (identifier name, string literal, or a template quasi's cooked text) and an internal expect("get string content") fires when a template-literal element has no usable quasi content. The method returns Option, so callers like is_name_equal already treat None as "no static name".
Source
Thrown at crates/oxc_linter/src/utils/jest/parse_jest_fn.rs:504
#[derive(Debug)]
pub struct KnownMemberExpressionProperty<'a> {
pub element: MemberExpressionElement<'a>,
pub parent: Option<&'a Expression<'a>>,
pub parent_kind: Option<KnownMemberExpressionParentKind>,
pub grandparent_kind: Option<KnownMemberExpressionParentKind>,
pub span: Span,
}
impl<'a> KnownMemberExpressionProperty<'a> {
pub fn name(&self) -> Option<Cow<'a, str>> {
match &self.element {
MemberExpressionElement::Expression(expr) => match expr {
Expression::Identifier(ident) => Some(Cow::Borrowed(ident.name.as_str())),
Expression::StringLiteral(string_literal) => {
Some(Cow::Borrowed(string_literal.value.as_str()))
}
Expression::TemplateLiteral(template_literal) => Some(Cow::Borrowed(
template_literal.single_quasi().expect("get string content").as_str(),
)),
_ => None,
},
MemberExpressionElement::IdentName(ident_name) => {
Some(Cow::Borrowed(ident_name.name.as_str()))
}
}
}
pub fn is_name_equal(&self, name: &str) -> bool {
self.name().is_some_and(|n| n == name)
}
pub fn is_name_unequal(&self, name: &str) -> bool {
!self.is_name_equal(name)
}
pub fn is_name_in_modifiers(&self, modifiers: &[ModifierName]) -> bool {View on GitHub (pinned to e1e7af627c)
Solutions
- Handle the computed/template element case explicitly and return None instead of unwrapping quasi content
- Guard with a check that the template has exactly the expected quasis before extracting text
- Keep matchers limited to identifier and string-literal property elements
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/oxc_linter/src/utils/jest/parse_jest_fn.rs:504 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/ada1edc4bf93dc27.
Report an issue: GitHub.