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

NullReferenceException when parsing instantiation of a previously partially specialised template #77

Open
s1sw opened this issue May 4, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@s1sw
Copy link

s1sw commented May 4, 2023

Parsing the following code causes a NullReferenceException:

template<typename A, typename B>
struct foo {};

template<typename B>
struct foo<int, B> {};

foo<int, int> foobar;

CppModelBuilder.GetOrCreateDeclarationContainer doesn't handle ClassTemplatePartialSpecialization cursors. This causes it to return null, which later causes the exception when trying to create a declaration container for the instantiation.

@xoofx xoofx added the bug Something isn't working label May 5, 2023
@xoofx
Copy link
Owner

xoofx commented May 5, 2023

@fangfang1984 as you have changed that code recently, maybe that's something you would have an interest to check/fix?

@fangfang1984
Copy link
Contributor

Ok, I will try to fix it.

@fangfang1984
Copy link
Contributor

I've attempted to reproduce this error on the latest CppAst.Net and found that the issue has already been fixed in recent adjustments. The TemplatePartialSpecialized should work properly in the new code. Please try again with the latest code, the corresponding 'foobar' field should now be recognized correctly.

@fangfang1984
Copy link
Contributor

This is an excellent sample code for verifying whether partial template specialization works correctly, i will try to add it to tests code.

@xoofx
Copy link
Owner

xoofx commented Jun 5, 2023

I've attempted to reproduce this error on the latest CppAst.Net and found that the issue has already been fixed in recent adjustments.

Releasing the latest commit, forgot to do it.

@fangfang1984
Copy link
Contributor

I've attempted to reproduce this error on the latest CppAst.Net and found that the issue has already been fixed in recent adjustments.

Releasing the latest commit, forgot to do it.

I've just added the sample code for partial specialized template and related feature enhancements, and submitted a PR (Pull Request).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants