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

cppyy fails to find template type with template type as final parameter #37

Closed
tristanpye opened this issue Feb 14, 2022 · 3 comments
Closed

Comments

@tristanpye
Copy link

If the final parameter of a templated typedef is a template type, then cppyy fails to find the type (unless the template type is the only parameter).

import cppyy

cppyy.cppdef('''
template<class T>
class F;

template<class T>
class V;

using i = F<void (int)>;
using v = F<void (V<int>)>;

using ii = F<void (int,int)>;
using iv = F<void (int,V<int>)>;  
using vi = F<void (V<int>,int)>;  
using vv = F<void (V<int>,V<int>)>;  

using iii = F<void (int,int,int)>;  
using ivi = F<void (int,V<int>,int)>;  
using vii = F<void (V<int>,int,int)>;  
using vvi = F<void (V<int>,V<int>,int)>;  

using iiv = F<void (int,int,V<int>)>;  
using ivv = F<void (int,V<int>,V<int>)>;  
using viv = F<void (V<int>,int,V<int>)>;  
using vvv = F<void (V<int>,V<int>,V<int>)>;  

''')

if __name__ == '__main__':
    for t in ['i','v',
              'ii', 'iv', 'vi', 'vv',
              'iii', 'ivi', 'vii', 'vvi',
              'iiv', 'ivv', 'viv', 'vvv']:
        try:
            cpp = getattr(cppyy.gbl,t)
            print(f'{t:5} ok')
        except AttributeError as e:
            print(f'{t:5} not found')

results in

i     ok
v     ok
ii    ok
iv    not found
vi    ok
vv    not found
iii   ok
ivi   ok
vii   ok
vvi   ok
iiv   not found
ivv   not found
viv   not found
vvv   not found

Real-world use of this was using std::function for F and std::vector for V, and various different types instead of int.

@wlav
Copy link
Owner

wlav commented Feb 14, 2022

Thanks for the nice reproducer!

Looks like a name parsing error in upstream (in all cases, the decl is actually found, but when constructing the internal names, they are each missing a ), leading to invalidation on the cppyy side). Will take some digging.

@wlav
Copy link
Owner

wlav commented Feb 15, 2022

Fixed in repo (cppyy-backend).

@wlav
Copy link
Owner

wlav commented Mar 8, 2022

Fix released with 2.3.0 and its dependencies.

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