diff --git a/src/engine.rs b/src/engine.rs index d0847bac..cd28772f 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -338,6 +338,7 @@ impl ChainArgument { /// Return the [position][Position]. #[inline(always)] #[must_use] + #[allow(dead_code)] pub const fn position(&self) -> Position { match self { #[cfg(not(feature = "no_object"))] diff --git a/tests/get_set.rs b/tests/get_set.rs index 5febe240..83dacc0b 100644 --- a/tests/get_set.rs +++ b/tests/get_set.rs @@ -224,25 +224,32 @@ fn test_get_set_chain_without_write_back() -> Result<(), Box> { "inner", |t: &mut Outer| t.inner.clone(), |_: &mut Outer, new: Inner| panic!("Outer::inner setter called with {:?}", new), - ) - .register_indexer_get_set( - |t: &mut Outer, n: INT| Inner { - value: t.inner.value * n, - }, - |_: &mut Outer, n: INT, new: Inner| { - panic!("Outer::inner index setter called with {} and {:?}", n, new) - }, ); + #[cfg(not(feature = "no_index"))] + engine.register_indexer_get_set( + |t: &mut Outer, n: INT| Inner { + value: t.inner.value * n, + }, + |_: &mut Outer, n: INT, new: Inner| { + panic!("Outer::inner index setter called with {} and {:?}", n, new) + }, + ); + assert_eq!( engine.eval_with_scope::(&mut scope, "outer.inner.value")?, 42 ); + + #[cfg(not(feature = "no_index"))] assert_eq!( engine.eval_with_scope::(&mut scope, "outer[2].value")?, 84 ); + engine.consume_with_scope(&mut scope, "print(outer.inner.value)")?; + + #[cfg(not(feature = "no_index"))] engine.consume_with_scope(&mut scope, "print(outer[0].value)")?; Ok(())