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

RuntimeError: generator raised StopIteration for a very simple code #159

Open
romintomasetti opened this issue Dec 8, 2020 · 0 comments

Comments

@romintomasetti
Copy link

I came across a code for which cppclean stops prematurely with

Traceback (most recent call last):
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 887, in _get_matching_char
    token = get_next_token()
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 904, in _get_next_token
    return next(self.tokens)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/romin/.local/bin/cppclean", line 166, in <module>
    sys.exit(main())
  File "/home/romin/.local/bin/cppclean", line 139, in main
    entire_ast = list([_f for _f in builder.generate() if _f])
  File "/home/romin/.local/bin/cppclean", line 139, in <listcomp>
    entire_ast = list([_f for _f in builder.generate() if _f])
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 675, in generate
    result = self._generate_one(token)
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 702, in _generate_one
    return method()
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 1246, in handle_class
    return self._handle_class_and_struct(Class)
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 1243, in _handle_class_and_struct
    return self._get_class(class_type, None)
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 1601, in _get_class
    return self._get_method(name_tokens, 0, None, False)
  File "/home/romin/.local/lib/python3.8/site-packages/cpp/ast.py", line 1009, in _get_method
    parameters = list(self._get_parameters())
RuntimeError: generator raised StopIteration

A MWE might be

#ifdef MYDEFINE
class Any
#else
class Any final
#endif
{
    public:
        Any(){};
};

int main()
{
    Any a;
    return 0;
} 

The problem is clearly caused by the #ifdef ... #endif statement surrounding the class.

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

1 participant