-
Notifications
You must be signed in to change notification settings - Fork 597
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
Fix error transforming an empty switch #346
Conversation
The parser would crash on that line for `switch(1) {}` because NoneType is not iterable. Fixes eliben#345
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change itself looks fine. Please add a test.
Done, asserted that the new block_items were |
tests/test_c_parser.py
Outdated
@@ -1799,6 +1799,7 @@ def assert_default_node(node): | |||
assert_case_node(block[2], '30') | |||
self.assertEqual(len(block[2].stmts), 1) | |||
assert_default_node(block[3]) | |||
self.assertEqual(len(block), 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move this test to before the assertions on block[...]
begin?
tests/test_c_parser.py
Outdated
switch = ps3.ext[0].body.block_items[0] | ||
|
||
block = switch.stmt.block_items | ||
self.assertEqual(block, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: block
is unnecessary here, just assert on switch.stmt.block_items
The parser would throw on that line for
switch(1) {}
because NoneType is not iterable.
Fixes #345