I've had similarly weird errors in python, but given the same situations its ever occurred to me in ruby. Maybe its just the way the grammar is defined, for example stuff like the following works perfectly fine in ruby while python just says "Invalid Syntax":
Of course, the point I was making is that it's perfectly possible to write a parser that understands newline as a terminator without sacrificing these idiosyncrasies.