apollographql / apollo-rs

Spec compliant GraphQL Tools in Rust.
Apache License 2.0
574 stars 45 forks source link

parser::ty::named_type() can silently do nothing #829

Open SimonSapin opened 9 months ago

SimonSapin commented 9 months ago

As found during https://github.com/apollographql/apollo-rs/pull/828. Current implementation:

pub(crate) fn named_type(p: &mut Parser) {
    if let Some(TokenKind::Name) = p.peek() {
        let _g = p.start_node(SyntaxKind::NAMED_TYPE);
        name::name(p);
    }
}

The caller has no way to tell if the if branch was taken without duplicating it outside of the function. Let’s check how this function is actually used and whether it’d be better to have it emit an error.

We should also check if there are other cases of this in the parser.