4 ms·
You can construct a linter that will prevent you from trying to add seconds to dollars.
by lrem 5y ago
You can construct a linter that will prevent you from trying to add seconds to dollars.
- akdor1154 5y agoA better example would be seconds to minutes. I think i recall a jwt related cve related to timestamps being misinterpreted between sec/ms for example.
- taneq 5y agoAdding seconds to minutes can actually make sense. A minute plus 30 seconds is 90 seconds, or 1.5 minutes. Whether your type system allows this, though, is up to the project. You can't add seconds to kilometers, or to temperature, or to how blue something is.
- OtomotO 5y agoIdeally you have a compiler that simply refuses to compile ambiguous code
- eurasiantiger 5y agoIdeally, there is no compiler.
- _flux 5y agoIdeally, you would detect all errors before runtime. Usually the compiler is the last gate to make that happen.
- eurasiantiger 5y agoIdeally, hardware execution would happen on a language that can be proven correct and does not allow the programmer to make syntactic or semantic errors. The world is far, far from ideal.
- CamperBob2 5y agoIsn't there an implicit conversion?