Just in case anyone else is as unobservant as I am: I got this error when I put a line of code inside a new class but not inside any methods (there were no methods yet and I wasn't paying attention).