I have to write the converter by myself. BindingType::toWireType is not easy, because the emscripten::val cannot be created using a c function. I create a C function wrapper to wrap the std::function ...
To replicate this error, it is necessary to add some debug statements to the expand_derivatives function. In the below MWE, that function is modified from version 6.12.0 only by adding debug printing.