Imagine a programming language that has physical measurement unit support so this could have never happened.
Like F#...? https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
Exactly. There are other languages that can do that or worst case you can implement it yourself (not sure how hard that is).