Numeric Substitution Issue in build_function (expression=Val{false})

Consider the simple code which defines a function of x using build_function

using Symbolics

@variables x
expr = exp(im*x)*cos(x)

# The option expression=Val{false} is supposed to force numerical evaluation.
f = build_function(expr, [x], expression=Val{false})

# Try to call the generated function with a numerical value.
result = f(0.8)
println("Result: ", result)

Ideally the result should be 0.48540023884935557 + 0.49978680152075255im but I get the output in terms of the symbolic variable Result: cos(x)^2 + im*sin(x)*cos(x)

I want the code to finally output a number. How can I fix this?

This looks like it’s a bug. Please file an issue and we’ll take a look. My guess is that some dispatch is on Real instead of Number so complex numbers are doing something odd.