3 ms·
But if the goto fail code had been run through an automated code formatter it would have been more obvious because the human indenting error would be fixed. Is
by profsnuggles 6y ago
But if the goto fail code had been run through an automated code formatter it would have been more obvious because the human indenting error would be fixed.
Is it possible to write a formatter that would fix an issue like that for yaml or python for example?
- ChrisSD 6y agoIf it were written in Python that particular category of bug simply could not exist. The human perceived block level always matches the machine read block level. In short, there's no issue to fix.
- mannykannot 6y agoCertainly not for python, which, for one thing, allows the nesting of 'if' with optional 'else'.
- falcolas 6y agoYes. There are two indicators for parsing Python blocks: indent and dedent. They're the same as { and }, and easily parsed by a machine. Just not by a regex, which so many formatting tools rely upon.
- profsnuggles 6y agoBut if I have if (test) do this; if (test) do that; and run it through a prettifier I end up with if (test) do this; if (test) do that; (Possibly I don't write a lot of c, and when I do I always use {} even if it's a single line statement) In python if I had a similar mis-indented construct how could you possibly know if it is supposed to be a nested if statement or not? I'm not picking on python I'm curious. My preferred language is clojure. I feel like the python whitespace is probably like lisp parens. It doesn't matter after the first week of learning. But when I'm typing clojure in emacs I don't care about formatting my code at all. Emacs sees the parens and indents correctly for me whenever I hit enter. I could probably write all my code on one line, run it through a code formatter and get a reasonable result. On the rare occasion I'm fixing some python when I start a new line I sometimes need to think about indenting and tab cycle until I hit the right depth.
- Gibbon1 6y agoThat terrifying thing to me was that a critical module like that obviously had no unit tests.