A truly idiotic investment when renewables are already cheaper than existing fossil fuel infrastructure (much less new infra)
Types of energy are not fungible. In some circumstances they are, but not always.
The entire planet is energy-constrained right now, there aren't enough solar panels or batteries to power all the demand we have, and the demand only continues to grow. We are so energy constrained in fact that people are trying seriously to deploy new nuclear in the US. Even with countries like China massively subsidizing solar, we're still not going to have enough renewable energy deployed.
This attitude misses the realities of scale bottlenecks and sunk costs.
If we ignore climate externalities, it makes sense to build solar as fast as we can and also pump oil, preferably for export.