The actual problem is that you do not include the definition of v in the flux_false function. If instead you would write
function first_step(x)
return sin.(x)
end
function second_step(x, v)
return x .* v
end
function flux(x)
v = first_step(x)
y = second_step(x, v)
return y
end
then everything would work smoothly. But your current flux_false treats v as an outside constant, with respect to which it doesn’t try to differentiate.