From 6de493c8c2167edcd1d08747c9f79a025a022df3 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 27 Oct 2022 22:25:18 +0800 Subject: [PATCH] Fix builds. --- src/types/error.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/types/error.rs b/src/types/error.rs index e18414de..7991c44f 100644 --- a/src/types/error.rs +++ b/src/types/error.rs @@ -1,6 +1,5 @@ //! Module containing error definitions for the evaluation process. -use crate::engine::{FN_GET, FN_IDX_GET, FN_IDX_SET, FN_SET}; use crate::{Dynamic, ImmutableString, ParseErrorType, Position, INT}; #[cfg(feature = "no_std")] use core_error::Error; @@ -184,22 +183,32 @@ impl fmt::Display for EvalAltResult { } Self::ErrorRuntime(d, ..) => write!(f, "Runtime error: {d}")?, - Self::ErrorNonPureMethodCallOnConstant(s, ..) if s.starts_with(FN_GET) => { - let prop = &s[FN_GET.len()..]; + #[cfg(not(feature = "no_object"))] + Self::ErrorNonPureMethodCallOnConstant(s, ..) + if s.starts_with(crate::engine::FN_GET) => + { + let prop = &s[crate::engine::FN_GET.len()..]; write!( f, "Property {prop} is not pure and cannot be accessed on a constant" )? } - Self::ErrorNonPureMethodCallOnConstant(s, ..) if s.starts_with(FN_SET) => { - let prop = &s[FN_SET.len()..]; + #[cfg(not(feature = "no_object"))] + Self::ErrorNonPureMethodCallOnConstant(s, ..) + if s.starts_with(crate::engine::FN_SET) => + { + let prop = &s[crate::engine::FN_SET.len()..]; write!(f, "Cannot modify property {prop} of constant")? } - Self::ErrorNonPureMethodCallOnConstant(s, ..) if s == FN_IDX_GET => write!( - f, - "Indexer is not pure and cannot be accessed on a constant" - )?, - Self::ErrorNonPureMethodCallOnConstant(s, ..) if s == FN_IDX_SET => { + #[cfg(not(feature = "no_index"))] + Self::ErrorNonPureMethodCallOnConstant(s, ..) if s == crate::engine::FN_IDX_GET => { + write!( + f, + "Indexer is not pure and cannot be accessed on a constant" + )? + } + #[cfg(not(feature = "no_index"))] + Self::ErrorNonPureMethodCallOnConstant(s, ..) if s == crate::engine::FN_IDX_SET => { write!(f, "Cannot assign to indexer of constant")? } Self::ErrorNonPureMethodCallOnConstant(s, ..) => {