Fixup code to make sure all feature builds succeed.
This commit is contained in:
parent
973153e832
commit
dd36f3387a
@ -8,7 +8,9 @@ use crate::engine::Engine;
|
||||
use crate::fn_register::{RegisterFn, RegisterResultFn};
|
||||
use crate::parser::{Position, INT};
|
||||
use crate::result::EvalAltResult;
|
||||
use crate::FLOAT;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use crate::parser::FLOAT;
|
||||
|
||||
use num_traits::{
|
||||
identities::Zero, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl,
|
||||
|
@ -1,6 +1,8 @@
|
||||
//! Helper module which defines `FnArgs` to make function calling easier.
|
||||
|
||||
use crate::any::{Any, Dynamic};
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
use crate::engine::Array;
|
||||
|
||||
/// Trait that represent arguments to a function call.
|
||||
|
@ -78,9 +78,12 @@ pub use call::FuncArgs;
|
||||
pub use engine::Engine;
|
||||
pub use error::{ParseError, ParseErrorType};
|
||||
pub use fn_register::{RegisterDynamicFn, RegisterFn, RegisterResultFn};
|
||||
pub use parser::{Position, AST, FLOAT, INT};
|
||||
pub use parser::{Position, AST, INT};
|
||||
pub use result::EvalAltResult;
|
||||
pub use scope::{Scope, ScopeEntry, VariableType};
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
pub use engine::Array;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
pub use parser::FLOAT;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![cfg(not(feature = "no_optimize"))]
|
||||
|
||||
use crate::engine::KEYWORD_DUMP_AST;
|
||||
use crate::parser::{Expr, Stmt};
|
||||
use crate::scope::{Scope, ScopeEntry, VariableType};
|
||||
|
23
src/scope.rs
23
src/scope.rs
@ -221,15 +221,6 @@ fn map_dynamic_to_expr(value: Dynamic) -> (Option<Expr>, Dynamic) {
|
||||
)),
|
||||
value2,
|
||||
)
|
||||
} else if value.is::<FLOAT>() {
|
||||
let value2 = value.clone();
|
||||
(
|
||||
Some(Expr::FloatConstant(
|
||||
*value.downcast::<FLOAT>().expect("value should be FLOAT"),
|
||||
Position::none(),
|
||||
)),
|
||||
value2,
|
||||
)
|
||||
} else if value.is::<char>() {
|
||||
let value2 = value.clone();
|
||||
(
|
||||
@ -261,6 +252,20 @@ fn map_dynamic_to_expr(value: Dynamic) -> (Option<Expr>, Dynamic) {
|
||||
value2,
|
||||
)
|
||||
} else {
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
{
|
||||
if value.is::<FLOAT>() {
|
||||
let value2 = value.clone();
|
||||
return (
|
||||
Some(Expr::FloatConstant(
|
||||
*value.downcast::<FLOAT>().expect("value should be FLOAT"),
|
||||
Position::none(),
|
||||
)),
|
||||
value2,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
(None, value)
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ fn test_constant() -> Result<(), EvalAltResult> {
|
||||
Ok(_) => panic!("expecting compilation error"),
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
match engine.eval::<i64>("const x = [1, 2, 3, 4, 5]; x[2] = 42;") {
|
||||
Err(EvalAltResult::ErrorAssignmentToConstant(var, _)) if var == "x" => (),
|
||||
Err(err) => return Err(err),
|
||||
|
@ -1,4 +1,7 @@
|
||||
use rhai::{Engine, EvalAltResult, FLOAT, INT};
|
||||
use rhai::{Engine, EvalAltResult, INT};
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use rhai::FLOAT;
|
||||
|
||||
#[test]
|
||||
fn test_power_of() -> Result<(), EvalAltResult> {
|
||||
|
Loading…
Reference in New Issue
Block a user