1
0

Complete index assignment

This commit is contained in:
Jeff 2023-11-14 21:03:52 -05:00
parent a804a85b1f
commit 98ea049229
2 changed files with 9 additions and 6 deletions

View File

@ -84,7 +84,7 @@ impl AbstractTree for IndexAssignment {
AssignmentOperator::Equal => value, AssignmentOperator::Equal => value,
}; };
context index_context
.variables_mut()? .variables_mut()?
.insert(index_key.clone(), new_value); .insert(index_key.clone(), new_value);

View File

@ -30,6 +30,8 @@ pub enum Statement {
impl AbstractTree for Statement { impl AbstractTree for Statement {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> { fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
Error::expect_syntax_node(source, "statement", node)?;
let child = node.child(0).unwrap(); let child = node.child(0).unwrap();
match child.kind() { match child.kind() {
@ -75,11 +77,12 @@ impl AbstractTree for Statement {
"index_assignment" => Ok(Statement::IndexAssignment(Box::new(IndexAssignment::from_syntax_node( "index_assignment" => Ok(Statement::IndexAssignment(Box::new(IndexAssignment::from_syntax_node(
source, child, source, child,
)?))), )?))),
_ => Err(Error::expect_syntax_node( _ => Err(Error::UnexpectedSyntaxNode {
source, expected: "assignment, expression, if...else, while, for, transform, filter, tool, async, find, remove, select, insert or index_assignment",
"assignment, expression, if...else, while, for, transform, filter, tool, async, find, remove, select, insert or index_assignment", actual: child.kind(),
child location: child.start_position(),
).unwrap_err()) relevant_source: source[child.byte_range()].to_string(),
}),
} }
} }