3 ms·
I'm not sure it's even possible to come up with a piece of code where a misplaced or missing semicolon causes a problem which isn't just a compiler error. If a
by rcxdude 13y ago
I'm not sure it's even possible to come up with a piece of code where a misplaced or missing semicolon causes a problem which isn't just a compiler error. If a semicolon is missing and there are more statements after it, the parser will complain ('foo' is not equivalent to 'return foo;' syntactically). If a semicolon is present but shouldn't be there will be a type error, unless the type without it would be (), in which case it makes no difference.
- kibwen 13y agoPrecisely. In other languages this would be a legitimate concern, and a lot of people (including myself!) immediately prickle upon learning of this feature before learning the ins and outs of the rest of the language. Fortunately, Rust's specific combination of features (most notably, that function signatures are not inferred, and must be typed explicitly) mean that I've never seen an error resulting from this in three years of using the language, and I've been unable to even contrive of an example where this could cause an error.