diff --git a/src/ast.rs b/src/ast.rs index 79aeb6f..39354de 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -19,7 +19,7 @@ pub enum Location { name: Ident, }, Field { - table: Box, + table: Box, index: Box, }, } diff --git a/src/run.rs b/src/run.rs index 9632f93..5707c67 100644 --- a/src/run.rs +++ b/src/run.rs @@ -183,7 +183,9 @@ mod tests { fn test_fields() { let mut scope = Scope::default(); let loc = ast::Location::Field { - table: Box::new(ast::Location::Variable { name: "foo".into() }), + table: Box::new(ast::Expression::Variable(ast::Location::Variable { + name: "foo".into(), + })), index: Box::new(ast::Expression::Constant(ast::Constant::String( "bar".into(), ))), @@ -249,7 +251,9 @@ mod tests { assert_eq!(bar.get("bar".into()), None); ast::Statement::Assign { target: ast::Location::Field { - table: Box::new(ast::Location::Variable { name: "foo".into() }), + table: Box::new(ast::Expression::Variable(ast::Location::Variable { + name: "foo".into(), + })), index: Box::new(ast::Expression::Constant(ast::Constant::String( "bar".into(), ))), diff --git a/src/twopass.rs b/src/twopass.rs index 2b29286..27b9200 100644 --- a/src/twopass.rs +++ b/src/twopass.rs @@ -37,7 +37,7 @@ enum Location { id: Ident, }, Field { - table: Box, + table: Box, index: Box, }, } @@ -156,12 +156,12 @@ fn lookup(scope: &BuildContext<'_>, loc: &ast::Location) -> Location { .request(&"_ENV".into()) .expect("_ENV must be always available"); Location::Field { - table: Box::new(Location::Variable { id: env }), + table: Box::new(Expression::Variable(Location::Variable { id: env })), index: Box::new(Expression::Constant(ast::Constant::String(name.clone()))), } } ast::Location::Field { table, index } => { - let table = Box::new(lookup(scope, &table)); + let table = Box::new(build_expression(scope, &table)); let index = Box::new(build_expression(scope, &index)); Location::Field { table, index } }