mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-01-31 08:59:15 +01:00
Fixed imaginary number being ignored in eval_fn_call
This commit is contained in:
parent
4da372aefe
commit
96a81b1359
@ -213,6 +213,7 @@ mod tests {
|
||||
KalkNum::new_with_imaginary(KalkNum::from(2f64).value, "", KalkNum::from(3f64).value),
|
||||
)
|
||||
.unwrap();
|
||||
println!("{}", result.to_f64());
|
||||
assert!(cmp(result.to_f64(), -4.5f64) || cmp(result.to_f64(), -4.499999f64));
|
||||
assert!(cmp(result.imaginary_to_f64(), 18f64));
|
||||
}
|
||||
|
@ -384,12 +384,19 @@ pub(crate) fn eval_fn_call_expr(
|
||||
// Initialise the arguments as their own variables.
|
||||
let mut new_argument_values = Vec::new();
|
||||
for (i, argument) in arguments.iter().enumerate() {
|
||||
let identifier_parts: Vec<&str> = argument.split('-').collect();
|
||||
let argument_identifier = if argument.contains("-") {
|
||||
let identifier_parts: Vec<&str> = argument.split('-').collect();
|
||||
Identifier::parameter_from_name(identifier_parts[1], identifier_parts[0])
|
||||
} else {
|
||||
Identifier::from_full_name(argument)
|
||||
};
|
||||
let var_decl = Stmt::VarDecl(
|
||||
Identifier::parameter_from_name(identifier_parts[1], identifier_parts[0]),
|
||||
Box::new(Expr::Literal(
|
||||
eval_expr(context, &expressions[i], "")?.to_f64(),
|
||||
)),
|
||||
argument_identifier,
|
||||
Box::new(crate::ast::build_literal_ast(&eval_expr(
|
||||
context,
|
||||
&expressions[i],
|
||||
"",
|
||||
)?)),
|
||||
);
|
||||
|
||||
// Don't set these values just yet, since
|
||||
|
Loading…
Reference in New Issue
Block a user