From 98ea04922955688047bc1ee7c24193b2059ce28a Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 14 Nov 2023 21:03:52 -0500 Subject: [PATCH] Complete index assignment --- src/abstract_tree/index_assignment.rs | 2 +- src/abstract_tree/statement.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/abstract_tree/index_assignment.rs b/src/abstract_tree/index_assignment.rs index 061c690..af71763 100644 --- a/src/abstract_tree/index_assignment.rs +++ b/src/abstract_tree/index_assignment.rs @@ -84,7 +84,7 @@ impl AbstractTree for IndexAssignment { AssignmentOperator::Equal => value, }; - context + index_context .variables_mut()? .insert(index_key.clone(), new_value); diff --git a/src/abstract_tree/statement.rs b/src/abstract_tree/statement.rs index 8821950..ab81277 100644 --- a/src/abstract_tree/statement.rs +++ b/src/abstract_tree/statement.rs @@ -30,6 +30,8 @@ pub enum Statement { impl AbstractTree for Statement { fn from_syntax_node(source: &str, node: Node) -> Result { + Error::expect_syntax_node(source, "statement", node)?; + let child = node.child(0).unwrap(); match child.kind() { @@ -75,11 +77,12 @@ impl AbstractTree for Statement { "index_assignment" => Ok(Statement::IndexAssignment(Box::new(IndexAssignment::from_syntax_node( source, child, )?))), - _ => Err(Error::expect_syntax_node( - source, - "assignment, expression, if...else, while, for, transform, filter, tool, async, find, remove, select, insert or index_assignment", - child - ).unwrap_err()) + _ => Err(Error::UnexpectedSyntaxNode { + expected: "assignment, expression, if...else, while, for, transform, filter, tool, async, find, remove, select, insert or index_assignment", + actual: child.kind(), + location: child.start_position(), + relevant_source: source[child.byte_range()].to_string(), + }), } }