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

Fix error transforming an empty switch #346

Merged
merged 3 commits into from
Aug 21, 2019

Conversation

TysonAndre
Copy link
Contributor

The parser would throw on that line for switch(1) {}
because NoneType is not iterable.

Fixes #345

The parser would crash on that line for `switch(1) {}`
because NoneType is not iterable.

Fixes eliben#345
Copy link
Owner

@eliben eliben left a 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.

@TysonAndre
Copy link
Contributor Author

TysonAndre commented Aug 21, 2019

Done, asserted that the new block_items were [] in test_switch_statement. I couldn't find that test the first time I looked.

@@ -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)
Copy link
Owner

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?

switch = ps3.ext[0].body.block_items[0]

block = switch.stmt.block_items
self.assertEqual(block, [])
Copy link
Owner

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

@eliben eliben merged commit a350f0d into eliben:master Aug 21, 2019
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

Successfully merging this pull request may close these issues.

"'NoneType' object is not iterable" seen for switch statement without cases
2 participants