Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of types matched as idents #1054

Merged
merged 7 commits into from
Apr 13, 2022

Conversation

Cerber-Ursi
Copy link
Contributor

The issue was originally discovered on URLO. Minimal example:

macro_rules! impl_id {
    ($typename:ident) => {
        #[juniper::graphql_object]
        impl $typename { // ERROR: could not determine ident for the `impl` type
            fn id(&self) -> i32 {
                42
            }
        }
    };
}

struct Unit;
impl_id!(Unit);

The reason for this error is the fact that, after being matched as ident, the identifier is not a bare ident anymore, it's a syn::TypeGroup, which is not handled correctly.

I've added the example above as test and modified the TypeExt::unparenthesized accordingly. It's entirely possible, however, that there are other places where either explicit match for TypeGroup or the call to unparenthesized should be added; I'm just not sure how to generate realistic test cases similar to the one above.


Side note: I wasn't able to run tests for this workspace, until I added features chrono and chrono-tz to the invocation. It's likely the consequence of #1010, and I'm not sure whether this is intentional (or desirable).

@tyranron tyranron added the enhancement Improvement of existing features or bugfix label Apr 13, 2022

Verified

This commit was signed with the committer’s verified signature.
tyranron Kai Ren

Verified

This commit was signed with the committer’s verified signature.
tyranron Kai Ren

Verified

This commit was signed with the committer’s verified signature.
tyranron Kai Ren
@tyranron tyranron added this to the 0.16.0 milestone Apr 13, 2022
Copy link
Member

@tyranron tyranron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cerber-Ursi thanks! 🍻

Very valuable addition. Didn't know about that nuance.

@tyranron tyranron added the k::api Related to API (application interface) label Apr 13, 2022

Verified

This commit was signed with the committer’s verified signature.
tyranron Kai Ren

Verified

This commit was signed with the committer’s verified signature.
tyranron Kai Ren

Verified

This commit was signed with the committer’s verified signature.
tyranron Kai Ren
@tyranron tyranron merged commit c40d80f into graphql-rust:master Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix k::api Related to API (application interface)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants