Fix builds.

This commit is contained in:
Stephen Chung 2022-10-27 22:25:18 +08:00
parent 25fde7dbed
commit 6de493c8c2

View File

@ -1,6 +1,5 @@
//! Module containing error definitions for the evaluation process. //! 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}; use crate::{Dynamic, ImmutableString, ParseErrorType, Position, INT};
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
use core_error::Error; use core_error::Error;
@ -184,22 +183,32 @@ impl fmt::Display for EvalAltResult {
} }
Self::ErrorRuntime(d, ..) => write!(f, "Runtime error: {d}")?, Self::ErrorRuntime(d, ..) => write!(f, "Runtime error: {d}")?,
Self::ErrorNonPureMethodCallOnConstant(s, ..) if s.starts_with(FN_GET) => { #[cfg(not(feature = "no_object"))]
let prop = &s[FN_GET.len()..]; Self::ErrorNonPureMethodCallOnConstant(s, ..)
if s.starts_with(crate::engine::FN_GET) =>
{
let prop = &s[crate::engine::FN_GET.len()..];
write!( write!(
f, f,
"Property {prop} is not pure and cannot be accessed on a constant" "Property {prop} is not pure and cannot be accessed on a constant"
)? )?
} }
Self::ErrorNonPureMethodCallOnConstant(s, ..) if s.starts_with(FN_SET) => { #[cfg(not(feature = "no_object"))]
let prop = &s[FN_SET.len()..]; 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")? write!(f, "Cannot modify property {prop} of constant")?
} }
Self::ErrorNonPureMethodCallOnConstant(s, ..) if s == FN_IDX_GET => write!( #[cfg(not(feature = "no_index"))]
f, Self::ErrorNonPureMethodCallOnConstant(s, ..) if s == crate::engine::FN_IDX_GET => {
"Indexer is not pure and cannot be accessed on a constant" write!(
)?, f,
Self::ErrorNonPureMethodCallOnConstant(s, ..) if s == FN_IDX_SET => { "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")? write!(f, "Cannot assign to indexer of constant")?
} }
Self::ErrorNonPureMethodCallOnConstant(s, ..) => { Self::ErrorNonPureMethodCallOnConstant(s, ..) => {