CppAst.NET icon indicating copy to clipboard operation
CppAst.NET copied to clipboard

NullReferenceException when parsing instantiation of a previously partially specialised template

Open s1sw opened this issue 2 years ago • 6 comments

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.

s1sw avatar May 04 '23 22:05 s1sw

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

xoofx avatar May 05 '23 05:05 xoofx

Ok, I will try to fix it.

fangfang1984 avatar May 11 '23 04:05 fangfang1984

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 avatar Jun 05 '23 03:06 fangfang1984

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

fangfang1984 avatar Jun 05 '23 03:06 fangfang1984

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.

xoofx avatar Jun 05 '23 05:06 xoofx

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).

fangfang1984 avatar Jun 05 '23 06:06 fangfang1984