Fix bug in chained dot/index expression.
This commit is contained in:
parent
76d792011f
commit
d7d49a5196
@ -1064,7 +1064,7 @@ impl Engine {
|
||||
// xxx.prop[expr] | xxx.prop.expr
|
||||
Expr::Index(x) | Expr::Dot(x) => {
|
||||
let (prop, expr, pos) = x.as_ref();
|
||||
let is_idx = matches!(expr, Expr::Index(_));
|
||||
let is_idx = matches!(rhs, Expr::Index(_));
|
||||
let args = &mut [obj, &mut Default::default()];
|
||||
|
||||
let (mut val, updated) = if let Expr::Property(p) = prop {
|
||||
@ -1102,7 +1102,7 @@ impl Engine {
|
||||
}
|
||||
// Syntax error
|
||||
_ => Err(Box::new(EvalAltResult::ErrorDotExpr(
|
||||
"".into(),
|
||||
format!("{:?}", rhs),
|
||||
rhs.position(),
|
||||
))),
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ fn test_map_indexing() -> Result<(), Box<EvalAltResult>> {
|
||||
)?,
|
||||
'o'
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let a = [#{s:"hello"}]; a[0].s[2] = 'X'; a[0].s"#)?,
|
||||
"heXlo"
|
||||
);
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
Loading…
Reference in New Issue
Block a user