Issue with NominalMetadataType.genericArguments()
sportlabsMike opened this issue · 4 comments
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.
Not to sure whats going on off the top of my head. Ill take a look soon. Thanks for the test case!
@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.
@wickwirew that nested-struct-crash
branch looks good. Thanks!
Awesome thanks! Its been merged and 2.1.0
has been released