fork of https://github.com/tree-sitter/tree-sitter-graph

Use same key for the values and the debug_infos map

Changed files
+14 -6
src
execution
lazy
+14 -6
src/execution/lazy/store.rs
··· 193 193 ) -> Result<HashMap<SyntaxNodeID, LazyValue>, ExecutionError> { 194 194 match values { 195 195 ScopedValues::Unforced(pairs) => { 196 - let mut map = HashMap::new(); 196 + let mut values = HashMap::new(); 197 197 let mut debug_infos = HashMap::new(); 198 198 for (scope, value, debug_info) in pairs.into_iter() { 199 199 let node = scope 200 200 .evaluate_as_syntax_node(exec) 201 201 .with_context(|| format!("Evaluating scope of variable _.{}", name,).into()) 202 202 .with_context(|| debug_info.0.clone().into())?; 203 - let prev_debug_info = debug_infos.insert(node, debug_info.clone()); 204 - match map.insert(node.index, value.clone()) { 205 - Some(_) => { 203 + match ( 204 + values.insert(node.index, value.clone()), 205 + debug_infos.insert(node.index, debug_info.clone()), 206 + ) { 207 + (Some(_), Some(prev_debug_info)) => { 206 208 return Err(ExecutionError::DuplicateVariable(format!( 207 209 "{}.{}", 208 210 node, name, 209 211 ))) 210 - .with_context(|| (prev_debug_info.unwrap().0, debug_info.0).into()); 212 + .with_context(|| (prev_debug_info.0, debug_info.0).into()); 213 + } 214 + (Some(_), None) => { 215 + unreachable!( 216 + "previous value for syntax node {} without previous debug info", 217 + node 218 + ) 211 219 } 212 220 _ => {} 213 221 }; 214 222 } 215 - Ok(map) 223 + Ok(values) 216 224 } 217 225 ScopedValues::Forcing => Err(ExecutionError::RecursivelyDefinedScopedVariable( 218 226 format!("_.{}", name),