|
|
|
|
|
by chmike
1587 days ago
|
|
There is a limit to the errors a compiler can detect. Here is an example where fuzzing is required. I'm the author of [qjson](https://github.com/qjson). It converts a human readable json text (qjson) into json. The intended use is for configuration files or data input. For instance, numeric values may be simple math expressions. I used go-fuzz and it detected right away that I forgot to deal with division by zero in these math expressions. It is impossible for the compiler to detect such errors in the program. It fully depends on the data, and when it is complex, the risk of errors are high. |
|
I'm sure there's a general class of problem where it really is impossible, but you haven't found it.
All you needed to prevent this is dependent types, which Go doesn't have. With dependent types the compiler sees a = b / c and it immediately can conclude that c's type is non-zero, since if it was zero that's a divide-by-zero error. Having refined the type to non-zero, an attempt earlier to load it with a value despite not being sure if that value is zero will fail. The buggy qjson won't compile.