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

Issue with NominalMetadataType.genericArguments() #42

Closed
sportlabsMike opened this issue Apr 24, 2019 · 4 comments
Closed

Issue with NominalMetadataType.genericArguments() #42

sportlabsMike opened this issue Apr 24, 2019 · 4 comments

Comments

@sportlabsMike
Copy link
Contributor

Hi,

I've been trying to get the GraphQL related https://github.com/GraphQLSwift/Graphiti project upgraded to Swift5 using the latest version of this library and came across a crash running the tests. The crash occurs in NominalMetadataType.genericArguments() when trying to get the TypeInfo for a simple Struct. I noticed that the Struct was declared nested within a closure.
It appears that NominalMetadataType.genericArguments() is coming back with a non-zero size results when it ought to be zero, and sometimes crashes.

To try and reproduce the problem within this project directly I've added a new test to MetadataTests.swift called testNestedStruct.

Please see this branch on my fork https://github.com/SportlabsTechnology/Runtime/tree/investigateCrash

Weirdly the addition of this new test causes the existing testStruct test to detect a non-zero amount of genericArguments and fail.

Any ideas ands help appreciated.
Thanks,
Mike.

@wickwirew wickwirew reopened this Apr 24, 2019
@wickwirew
Copy link
Owner

Not to sure whats going on off the top of my head. Ill take a look soon. Thanks for the test case!

@wickwirew
Copy link
Owner

@sportlabsMike Not too sure why it being nested within a function is messing it up. If the nested struct was generic it would work.

Ended up getting it to work by checking the metadata flags to make sure the type is generic before trying to read the arguments.

I have a branch if you wouldn't mind testing it out: nested-struct-crash. If that fixes your issue Ill merge it.

@sportlabsMike
Copy link
Contributor Author

@wickwirew that nested-struct-crash branch looks good. Thanks!

@wickwirew
Copy link
Owner

Awesome thanks! Its been merged and 2.1.0 has been released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants