I have this query and tested in Setup/System Log/ Execute Apex and it works fine.
SELECT Account.Name, (SELECT Contact.LastName FROM Account.Contacts) FROM Account
However, I plugged this query in my app and it doesn't work. and it give me this error.
INVALID_TYPE: sObject type 'account.contacts)' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.
If I remove (SELECT Contact.LastName FROM Account.Contacts), then it works fine.