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

Force all lazy values to catch hidden problems

Changed files
+21 -10
src
execution
+14 -10
src/execution/lazy.rs
··· 90 90 )?; 91 91 } 92 92 93 + let mut exec = EvaluationContext { 94 + source, 95 + graph, 96 + functions: config.functions, 97 + store: &store, 98 + scoped_store: &scoped_store, 99 + function_parameters: &mut function_parameters, 100 + prev_element_debug_info: &mut prev_element_debug_info, 101 + cancellation_flag, 102 + }; 93 103 for graph_stmt in &lazy_graph { 94 - graph_stmt.evaluate(&mut EvaluationContext { 95 - source, 96 - graph, 97 - functions: config.functions, 98 - store: &mut store, 99 - scoped_store: &mut scoped_store, 100 - function_parameters: &mut function_parameters, 101 - prev_element_debug_info: &mut prev_element_debug_info, 102 - cancellation_flag, 103 - })?; 104 + graph_stmt.evaluate(&mut exec)?; 104 105 } 106 + // make sure any unforced values are now forced, to surface any problems 107 + // hidden by the fact that the values were unused 108 + store.evaluate_all(&mut exec)?; 105 109 106 110 Ok(()) 107 111 }
+7
src/execution/lazy/store.rs
··· 82 82 let value = variable.force(exec).with_context(|| debug_info.0.into())?; 83 83 Ok(value) 84 84 } 85 + 86 + pub(super) fn evaluate_all(&self, exec: &mut EvaluationContext) -> Result<(), ExecutionError> { 87 + for variable in &self.elements { 88 + variable.force(exec)?; 89 + } 90 + Ok(()) 91 + } 85 92 } 86 93 87 94 /// Data structure to hold scoped variables with lazy keys and values