diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ba1bc4f..df828457 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Version 1.13.0 Bug fixes --------- +* Complex indexing/dotting chains now parse correctly, for example: `a[b][c[d]].e` * `map` and `filter` for arrays are marked `pure`. Warnings are added to the documentation of pure array methods that take `this` closures. diff --git a/src/parser.rs b/src/parser.rs index 60454e37..1230dbfc 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2102,8 +2102,10 @@ impl Engine { op_pos: Position, ) -> ParseResult { match (lhs, rhs) { - // lhs[idx_expr].rhs - (Expr::Index(mut x, options, pos), rhs) => { + // lhs[...][...].rhs + (Expr::Index(mut x, options, pos), rhs) + if !parent_options.contains(ASTFlags::BREAK) => + { let options = options | parent_options; x.rhs = Self::make_dot_expr(state, x.rhs, rhs, options, op_flags, op_pos)?; Ok(Expr::Index(x, ASTFlags::NONE, pos)) diff --git a/tests/arrays.rs b/tests/arrays.rs index e0d5226e..fe8b7b81 100644 --- a/tests/arrays.rs +++ b/tests/arrays.rs @@ -133,6 +133,20 @@ fn test_arrays() -> Result<(), Box> { ); } + #[cfg(not(feature = "no_object"))] + assert_eq!( + engine.eval::( + " + let x = #{ foo: 42 }; + let n = 0; + let a = [[x]]; + let i = [n]; + a[n][i[n]].foo + " + )?, + 42 + ); + assert_eq!( engine .eval::(