Check for illegal syntax in types (fixes Trac #7943)