zed-industries/zed · error
resolving a native parseable language cannot fail
Error message
resolving a native parseable language cannot fail
What it means
Asserts that resolving a native (non-WASM) grammar's language always succeeds — resolution here is just returning the statically linked tree-sitter language, which cannot fail by construction. The unwrap documents an invariant of native grammars; if it ever fires, the native grammar registry returned a grammar whose native handle is absent, i.e., an internal registration bug rather than bad input.
Source
Thrown at crates/language_core/src/grammar.rs:341
.ok()
.and_then(|ts_language| Query::new(&ts_language, "(ERROR) @error").ok());
Self {
id: GrammarId::new(),
highlights_config: None,
brackets_config: None,
outline_config: None,
text_object_config: None,
indents_config: None,
injection_config: None,
override_config: None,
redactions_config: None,
runnable_config: None,
error_query,
debug_variables_config: None,
#[cfg(not(target_family = "wasm"))]
ts_language: parseable_language
.resolve()
.expect("resolving a native parseable language cannot fail"),
#[cfg(target_family = "wasm")]
parseable_language,
highlight_map: Default::default(),
}
}
/// A parseable [`tree_sitter::Language`] valid on the calling thread.
///
/// See [`ParseableLanguage`] for why this is a resolution rather than a
/// field access on WebAssembly.
pub fn parseable_language(&self) -> Result<tree_sitter::Language> {
#[cfg(not(target_family = "wasm"))]
{
Ok(self.ts_language.clone())
}
#[cfg(target_family = "wasm")]
{
self.parseable_language.resolve()View on GitHub (pinned to 9d272b0363)
Solutions
- Audit native grammar registration to ensure every native Grammar carries its tree-sitter language
- Return a Result from resolution and surface a descriptive error listing the grammar name
- Add a registration test that resolves every native grammar once
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/language_core/src/grammar.rs:339 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/c7d86848e82b2ca5.
Report an issue: GitHub.