I periodically hit that ReplaceText is buggy when hit nodes with implicit casts. This bug does not occur in single-replacement cases, it only reproduces when I try to make a recursive code rewriter. For example, I want to rewrite expressions with complex numbers from C++ to pure C using functions.
Input:
complex test_bug(complex cosTheta, complex eta, float lambda)
{
return cosTheta + eta/lambda;
}
complex test_ok(complex cosTheta, complex eta, float lambda)
{
return cosTheta + eta/complex(lambda);
}
Output:
complex test_bug(complex cosTheta, complex eta, float lambda)
{
return complex_add(cosTheta,complex_div(eta,to_com))plex(lambda);
}
complex test_ok(complex cosTheta, complex eta, float lambda)
{
return complex_add(cosTheta,complex_div(eta,to_complex(lambda)));
}
The minimal example is here