If you put diesel in a petrol engine, it’d cause knocking, which would eventually cause serious damage. As for diesel engines, they use the fuel itself as a lubricant. Using petrol would eventually cause wear on the engine and corrode seals. Diesel engines are stronger than petrol ones, so on balance it’s probably worse to put diesel in a petrol engine.